Skip to content

Instantly share code, notes, and snippets.

@seksenov
Last active May 28, 2022 21:51
Show Gist options
  • Select an option

  • Save seksenov/17032e9a6eb9c17f88b5 to your computer and use it in GitHub Desktop.

Select an option

Save seksenov/17032e9a6eb9c17f88b5 to your computer and use it in GitHub Desktop.

Revisions

  1. seksenov revised this gist Jun 30, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cortana.html
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    <html>
    <head>
    <title>Cortana Example</title>
    <!--Cortana meta tag pointing to VCD file on the server-->
    <!--Cortana meta tag pointing to VCD file on the server-->
    <meta name="msapplication-cortanavcd" content="https://mysite.com/vcd.xml"/>
    </head>
    <body>
  2. seksenov revised this gist Jun 30, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion cortana.html
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    <html>
    <head>
    <title>Cortana Example</title>
    <!--Cortana meta tag-->
    <!--Cortana meta tag pointing to VCD file on the server-->
    <meta name="msapplication-cortanavcd" content="https://mysite.com/vcd.xml"/>
    </head>
    <body>
  3. seksenov created this gist Jun 30, 2015.
    11 changes: 11 additions & 0 deletions cortana.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <!DOCTYPE html>
    <html>
    <head>
    <title>Cortana Example</title>
    <!--Cortana meta tag-->
    <meta name="msapplication-cortanavcd" content="https://mysite.com/vcd.xml"/>
    </head>
    <body>

    </body>
    </html>
    33 changes: 33 additions & 0 deletions cortana.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    if (typeof Windows !== 'undefined' &&
    typeof Windows.UI !== 'undefined' &&
    typeof Windows.ApplicationModel !== 'undefined')
    {
    // Subscribe to the Windows Activation Event
    Windows.UI.WebUI.WebUIApplication.addEventListener("activated", function (args) {
    var activation = Windows.ApplicationModel.Activation;
    // Check to see if the app was activated by a voice command
    if (args.kind === activation.ActivationKind.voiceCommand) {
    // Get the speech reco
    var speechRecognitionResult = args.result;
    var textSpoken = speechRecognitionResult.text;
    // Determine the command type {search} defined in vcd
    if (speechRecognitionResult.rulePath[0] === "search") {
    // Determine the stream name specified
    if (textSpoken.includes('foo') || textSpoken.includes('Foo')) {
    console.log("The user is searching for foo");
    }
    else if (textSpoken.includes('bar') || textSpoken.includes('Bar') ) {
    console.log("The user is searching for a bar");
    }
    else {
    console.log("Invalid search term specified by user");
    }
    }
    else {
    console.log("No valid command specified");
    }
    }
    });
    } else {
    console.log("Windows namespace is unavaiable");
    }
    14 changes: 14 additions & 0 deletions vcd.xml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    <?xml version="1.0" encoding="utf-8"?>
    <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
    <CommandSet xml:lang="en-us" Name="RJS">
    <CommandPrefix>MyApp</CommandPrefix>
    <Example>MyApp search for foo</Example>
    <Command Name="Search">
    <Example>search {message} using myapp</Example>
    <ListenFor RequireAppName="BeforeOrAfterPhrase">Search for {searchTerm}</ListenFor>
    <Feedback>Searching for {searchTerm} with MyApp</Feedback>
    <Navigate Target="/search.htm"/>
    </Command>
    <PhraseTopic Label="searchTerm" Scenario="Dictation"></PhraseTopic>
    </CommandSet>
    </VoiceCommands>