SlideShare a Scribd company logo
1 of 28
Rodolfo Finochietti – Software Architect
rodolfof@lagash.com
@rodolfof
Mariano Sánchez – Software Architect
marianos@lagash.com
@marianosz
Cortana: What Can You Do?
Integrate with Cortana in 3 Easy Steps:
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-us" Name="englishCommands">
<CommandPrefix>MSDN</CommandPrefix>
<Example>How do I add Voice Commands to my application</Example>
<Command Name="FindText">
<Example>Find Install Voice Command Sets</Example>
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<Feedback>Search on MSDN</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<Command Name="nlpCommand">
<Example>How do I add Voice Commands to my application</Example>
<ListenFor>{dictatedVoiceCommandText}</ListenFor>
<Feedback>Starting MSDN...</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">
<Subject>MSDN</Subject>
</PhraseTopic>
<PhraseTopic Label="dictatedSearchTerms" Scenario="Search">
<Subject>MSDN</Subject>
</PhraseTopic>
</CommandSet>
</VoiceCommands>
Create Voice Command Definition(s)
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-us" Name="englishCommands">
<CommandPrefix>MSDN</CommandPrefix>
<Example>How do I add Voice Commands to my application</Example>
<Command Name="FindText">
<Example>Find Install Voice Command Sets</Example>
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<Feedback>Search on MSDN</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<Command Name="nlpCommand">
<Example>How do I add Voice Commands to my application</Example>
<ListenFor>{dictatedVoiceCommandText}</ListenFor>
<Feedback>Starting MSDN...</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">
<Subject>MSDN</Subject>
</PhraseTopic>
<PhraseTopic Label="dictatedSearchTerms" Scenario="Search">
<Subject>MSDN</Subject>
</PhraseTopic>
</CommandSet>
</VoiceCommands>
Create Voice Command Definition(s)
<CommandPrefix>MSDN</CommandPrefix>
Create Voice Command Definition(s)
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-us" Name="englishCommands">
<CommandPrefix>MSDN</CommandPrefix>
<Example>How do I add Voice Commands to my application</Example>
<Command Name="FindText">
<Example>Find Install Voice Command Sets</Example>
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<Feedback>Search on MSDN</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<Command Name="nlpCommand">
<Example>How do I add Voice Commands to my application</Example>
<ListenFor>{dictatedVoiceCommandText}</ListenFor>
<Feedback>Starting MSDN...</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">
<Subject>MSDN</Subject>
</PhraseTopic>
<PhraseTopic Label="dictatedSearchTerms" Scenario="Search">
<Subject>MSDN</Subject>
</PhraseTopic>
</CommandSet>
</VoiceCommands>
<Example>How do I add Voice Commands to my
application</Example>
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-us" Name="englishCommands">
<CommandPrefix>MSDN</CommandPrefix>
<Example>How do I add Voice Commands to my application</Example>
<Command Name="FindText">
<Example>Find Install Voice Command Sets</Example>
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<Feedback>Search on MSDN</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<Command Name="nlpCommand">
<Example>How do I add Voice Commands to my application</Example>
<ListenFor>{dictatedVoiceCommandText}</ListenFor>
<Feedback>Starting MSDN...</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">
<Subject>MSDN</Subject>
</PhraseTopic>
<PhraseTopic Label="dictatedSearchTerms" Scenario="Search">
<Subject>MSDN</Subject>
</PhraseTopic>
</CommandSet>
</VoiceCommands>
Create Voice Command Definition(s)<Command Name="FindText">
<Example>Find Install Voice Command Sets</Example>
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<Feedback>Search on MSDN</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<Command Name="nlpCommand">
<Example>How do I add Voice Commands to my application</Example>
<ListenFor>{dictatedVoiceCommandText}</ListenFor>
<Feedback>Starting MSDN...</Feedback>
<Navigate Target="MainPage.xaml" />
/Command>
Create Voice Command Definition(s)
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-us" Name="englishCommands">
<CommandPrefix>MSDN</CommandPrefix>
<Example>How do I add Voice Commands to my application</Example>
<Command Name="FindText">
<Example>Find Install Voice Command Sets</Example>
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<Feedback>Search on MSDN</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<Command Name="nlpCommand">
<Example>How do I add Voice Commands to my application</Example>
<ListenFor>{dictatedVoiceCommandText}</ListenFor>
<Feedback>Starting MSDN...</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">
<Subject>MSDN</Subject>
</PhraseTopic>
<PhraseTopic Label="dictatedSearchTerms" Scenario="Search">
<Subject>MSDN</Subject>
</PhraseTopic>
</CommandSet>
</VoiceCommands>
<Example>Find Install Voice Command Sets</Example>
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-us" Name="englishCommands">
<CommandPrefix>MSDN</CommandPrefix>
<Example>How do I add Voice Commands to my application</Example>
<Command Name="FindText">
<Example>Find Install Voice Command Sets</Example>
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<Feedback>Search on MSDN</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<Command Name="nlpCommand">
<Example>How do I add Voice Commands to my application</Example>
<ListenFor>{dictatedVoiceCommandText}</ListenFor>
<Feedback>Starting MSDN...</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">
<Subject>MSDN</Subject>
</PhraseTopic>
<PhraseTopic Label="dictatedSearchTerms" Scenario="Search">
<Subject>MSDN</Subject>
</PhraseTopic>
</CommandSet>
</VoiceCommands>
Create Voice Command Definition(s)
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
Create Voice Command Definition(s)
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-us" Name="englishCommands">
<CommandPrefix>MSDN</CommandPrefix>
<Example>How do I add Voice Commands to my application</Example>
<Command Name="FindText">
<Example>Find Install Voice Command Sets</Example>
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<Feedback>Search on MSDN</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<Command Name="nlpCommand">
<Example>How do I add Voice Commands to my application</Example>
<ListenFor>{dictatedVoiceCommandText}</ListenFor>
<Feedback>Starting MSDN...</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">
<Subject>MSDN</Subject>
</PhraseTopic>
<PhraseTopic Label="dictatedSearchTerms" Scenario="Search">
<Subject>MSDN</Subject>
</PhraseTopic>
</CommandSet>
</VoiceCommands>
<Feedback>Search on MSDN</Feedback>
Create Voice Command Definition(s)
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-us" Name="englishCommands">
<CommandPrefix>MSDN</CommandPrefix>
<Example>How do I add Voice Commands to my application</Example>
<Command Name="FindText">
<Example>Find Install Voice Command Sets</Example>
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<Feedback>Search on MSDN</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<Command Name="nlpCommand">
<Example>How do I add Voice Commands to my application</Example>
<ListenFor>{dictatedVoiceCommandText}</ListenFor>
<Feedback>Starting MSDN...</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">
<Subject>MSDN</Subject>
</PhraseTopic>
<PhraseTopic Label="dictatedSearchTerms" Scenario="Search">
<Subject>MSDN</Subject>
</PhraseTopic>
</CommandSet>
</VoiceCommands>
<Navigate Target="MainPage.xaml" />
Create Voice Command Definition(s)
<?xml version="1.0" encoding="utf-8"?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1">
<CommandSet xml:lang="en-us" Name="englishCommands">
<CommandPrefix>MSDN</CommandPrefix>
<Example>How do I add Voice Commands to my application</Example>
<Command Name="FindText">
<Example>Find Install Voice Command Sets</Example>
<ListenFor>Search</ListenFor>
<ListenFor>Search for {dictatedSearchTerms}</ListenFor>
<ListenFor>Find</ListenFor>
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<Feedback>Search on MSDN</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<Command Name="nlpCommand">
<Example>How do I add Voice Commands to my application</Example>
<ListenFor>{dictatedVoiceCommandText}</ListenFor>
<Feedback>Starting MSDN...</Feedback>
<Navigate Target="MainPage.xaml" />
</Command>
<PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">
<Subject>MSDN</Subject>
</PhraseTopic>
<PhraseTopic Label="dictatedSearchTerms" Scenario="Search">
<Subject>MSDN</Subject>
</PhraseTopic>
</CommandSet>
</VoiceCommands>
<PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation">
<Subject>MSDN</Subject>
</PhraseTopic>
<PhraseTopic Label="dictatedSearchTerms" Scenario="Search">
<Subject>MSDN</Subject>
</PhraseTopic>
private async void
// SHOULD BE PERFORMED UNDER TRY/CATCH
Uri new ms-appx:///vcd.xml UriKind.Absolute
await
Windows Phone Silverlight Apps on Windows Phone 8.1
Windows Runtime Apps on Windows Phone 8.1
private async void
// SHOULD BE PERFORMED UNDER TRY/CATCH
Uri uriVoiceCommands = new Uri("ms-appx:///vcd.xml", UriKind.Absolute);
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uriVoiceCommands);
await VoiceCommandManager.InstallCommandSetsFromStorageFileAsync(file);
Register VCD XML file on App Startup
Handle Voice Command Activation
❶
❷
❸
// Windows Runtime App on Windows Phone 8.1, inside OnActivated override in App class
if (args.Kind == ActivationKind.VoiceCommand)
{
VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args;
string voiceCommandName = vcArgs.Result.RulePath.First(); // What command launched the app?
switch (voiceCommandName) // Navigate to right page for the voice command
{
case "FindText": // User said "find" or "search"
rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result);
break;
case "nlpCommand": // User said something else
rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result);
break;
}
}
Handle Voice Command Activation
// Windows Runtime App on Windows Phone 8.1, inside OnActivated override in App class
if (args.Kind == ActivationKind.VoiceCommand)
{
VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args;
string voiceCommandName = vcArgs.Result.RulePath.First(); // What command launched the app?
switch (voiceCommandName) // Navigate to right page for the voice command
{
case "FindText": // User said "find" or "search"
rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result);
break;
case "nlpCommand": // User said something else
rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result);
break;
}
}
Handle Voice Command Activation
// Windows Runtime App on Windows Phone 8.1, inside OnActivated
override
// in App class
if (args.Kind == ActivationKind.VoiceCommand)
// Windows Runtime App on Windows Phone 8.1, inside OnActivated override in App class
if (args.Kind == ActivationKind.VoiceCommand)
{
VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args;
string voiceCommandName = vcArgs.Result.RulePath.First(); // What command launched the app?
switch (voiceCommandName) // Navigate to right page for the voice command
{
case "FindText": // User said "find" or "search"
rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result);
break;
case "nlpCommand": // User said something else
rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result);
break;
}
}
Handle Voice Command Activation
VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args;
// What command launched the app?
string voiceCommandName = vcArgs.Result.RulePath.First();
// Navigate to right page for the voice command
switch (voiceCommandName)
// Windows Runtime App on Windows Phone 8.1, inside OnActivated override in App class
if (args.Kind == ActivationKind.VoiceCommand)
{
VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args;
string voiceCommandName = vcArgs.Result.RulePath.First(); // What command launched the app?
switch (voiceCommandName) // Navigate to right page for the voice command
{
case "FindText": // User said "find" or "search"
rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result);
break;
case "nlpCommand": // User said something else
rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result);
break;
}
}
Handle Voice Command Activation
// Navigate to right page for the voice command
switch (voiceCommandName)
{
case "FindText": // User said "find" or "search"
rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result);
break;
case "nlpCommand": // User said something else
rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result);
break;
}
// Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo in FindText.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Get recognition result from parameter passed in frame.Navigate call
SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult;
if (vcResult!=null)
{
// What did the user say? e.g. MSDN, "Find Windows Phone Voice Commands"
string recoText = vcResult.Text;
// Store the semantics dictionary for later use
IReadOnlyDictionary<string,IReadOnlyList<string>> semantics = vcResult.SemanticInterpretation.Properties;
string voiceCommandName = vcResult.RulePath.First();
if (voiceCommandName == "FindText")
{
// What did the user say, for named phrase topic or list "slots"? e.g. "Windows Phone Voice Commands"
if (semantics.ContainsKey("dictatedSearchTerms"))
{
HandleFindTextWithSearchTerms(semantics["dictatedSearchTerms"][0]);
}
else
{
HandleNoSearchTerms();
}
}
// Else handle other voice commands
} navigationHelper.OnNavigatedTo(e)
Handle Voice Command Activation
// Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo In FindText.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Get recognition result from parameter passed in frame.Navigate call
SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult;
if (vcResult!=null)
{
// What did the user say? e.g. MSDN, "Find Windows Phone Voice Commands"
string recoText = vcResult.Text;
// Store the semantics dictionary for later use
IReadOnlyDictionary<string,IReadOnlyList<string>> semantics = vcResult.SemanticInterpretation.Properties;
string voiceCommandName = vcResult.RulePath.First();
if (voiceCommandName == "FindText")
{
// What did the user say, for named phrase topic or list "slots"? e.g. "Windows Phone Voice Commands"
if (semantics.ContainsKey("dictatedSearchTerms"))
{
HandleFindTextWithSearchTerms(semantics["dictatedSearchTerms"][0]);
}
else
{
HandleNoSearchTerms();
}
}
// Else handle other voice commands
} navigationHelper.OnNavigatedTo(e)
Handle Voice Command Activation
// Windows Runtime App on Windows Phone 8.1, inside
// OnNavigatedTo in FindText.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Get recognition result from parameter passed in frame.Navigate call
SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult;
if (vcResult!=null)
{
// What did the user say? e.g. MSDN, "Find Windows Phone Voice
Commands"
string recoText = vcResult.Text;
// Store the semantics dictionary for later use
IReadOnlyDictionary<string,IReadOnlyList<string>> semantics =
vcResult.SemanticInterpretation.Properties;
string voiceCommandName = vcResult.RulePath.First();
// Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo In FindText.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Get recognition result from parameter passed in frame.Navigate call
SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult;
if (vcResult!=null)
{
// What did the user say? e.g. MSDN, "Find Windows Phone Voice Commands"
string recoText = vcResult.Text;
// Store the semantics dictionary for later use
IReadOnlyDictionary<string,IReadOnlyList<string>> semantics = vcResult.SemanticInterpretation.Properties;
string voiceCommandName = vcResult.RulePath.First();
if (voiceCommandName == "FindText")
{
// What did the user say, for named phrase topic or list "slots"? e.g. "Windows Phone Voice Commands"
if (semantics.ContainsKey("dictatedSearchTerms"))
{
HandleFindTextWithSearchTerms(semantics["dictatedSearchTerms"][0]);
}
else
{
HandleNoSearchTerms();
}
}
// Else handle other voice commands
} navigationHelper.OnNavigatedTo(e)
}
Handle Voice Command Activation
if (voiceCommandName == "FindText")
{
// What did the user say, for named phrase topic or list "slots"?
// e.g. "Windows Phone Voice Commands"
if (semantics.ContainsKey("dictatedSearchTerms"))
{
HandleFindTextWithSearchTerms(semantics["dictatedSearchTerms"][0]);
}
else
{
HandleNoSearchTerms();
}
}
// Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo in NlpCommand.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// Get recognition result from parameter passed in frame.Navigate call
SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult;
// Check for null!
string commandMode = vcResult.SemanticInterpretation.Properties["commandMode"][0];
if (commandMode == "voice") // Did the user speak or type the command?
{
SpeakText(audioPlayer, String.Format("MSDN app heard you say {0}", vcResult.Text));
HandleNlpCommand(vcResult);
}
else if(commandMode=="text")
{
messageTextBox.Text = string.Format("Working on your request "{0}"", vcResult.Text);
HandleNlpCommand(vcResult);
}
}
Handle Voice Command Activation
// Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo In NlpCommand.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// Get recognition result from parameter passed in frame.Navigate call
SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult;
// Check for null!
string commandMode = vcResult.SemanticInterpretation.Properties["commandMode"][0];
if (commandMode == "voice") // Did the user speak or type the command?
{
SpeakText(audioPlayer, String.Format("MSDN app heard you say {0}", vcResult.Text));
HandleNlpCommand(vcResult);
}
else if(commandMode=="text")
{
messageTextBox.Text = string.Format("Working on your request "{0}"", vcResult.Text);
HandleNlpCommand(vcResult);
}
}
Handle Voice Command Activation
// Windows Runtime App on Windows Phone 8.1, in OnNavigatedTo in NlpCommand.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Get recognition result from parameter passed in frame.Navigate call
SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult;
string commandMode =
vcResult.SemanticInterpretation.Properties["commandMode"][0];
// Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo In NlpCommand.xaml.cs
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// Get recognition result from parameter passed in frame.Navigate call
SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult;
// Check for null!
string commandMode = vcResult.SemanticInterpretation.Properties["commandMode"][0];
if (commandMode == "voice") // Did the user speak or type the command?
{
SpeakText(audioPlayer, String.Format("MSDN app heard you say {0}", vcResult.Text));
HandleNlpCommand(vcResult);
}
else if(commandMode=="text")
{
messageTextBox.Text = string.Format("Working on your request "{0}"", vcResult.Text);
HandleNlpCommand(vcResult);
}
}
Handle
string commandMode = vcResult.SemanticInterpretation.Properties["commandMode"][0];
if (commandMode == "voice") // Did the user speak or type the command?
{
SpeakText(audioPlayer, String.Format("MSDN voice heard you say {0}",
vcResult.Text));
HandleNlpCommand(vcResult);
}
else if(commandMode=="text")
{
msgTextBox.Text= string.Format("Working on your request "{0}"", vcResult.Text);
HandleNlpCommand(vcResult);
}
Muchas Gracias
Rodolfo Finochietti – Software Architect
rodolfof@lagash.com
@rodolfof
Mariano Sánchez – Software Architect
marianos@lagash.com
@marianosz

More Related Content

Similar to Hey Cortana!

Beyond Cortana & Siri: Using Speech Recognition & Speech Synthesis for the Ne...
Beyond Cortana & Siri: Using Speech Recognition & Speech Synthesis for the Ne...Beyond Cortana & Siri: Using Speech Recognition & Speech Synthesis for the Ne...
Beyond Cortana & Siri: Using Speech Recognition & Speech Synthesis for the Ne...Nick Landry
 
TDC 2014 - Cortana
TDC 2014 - CortanaTDC 2014 - Cortana
TDC 2014 - Cortanatmonaco
 
Fonctions vocales sous Windows Phone : intégrez votre application à Cortana !
Fonctions vocales sous Windows Phone : intégrez votre application à Cortana !Fonctions vocales sous Windows Phone : intégrez votre application à Cortana !
Fonctions vocales sous Windows Phone : intégrez votre application à Cortana !Microsoft
 
Windows Phone 8 - 14 Using Speech
Windows Phone 8 - 14 Using SpeechWindows Phone 8 - 14 Using Speech
Windows Phone 8 - 14 Using SpeechOliver Scheer
 
Developing with Speech and Voice Recognition in Mobile Apps
Developing with Speech and Voice Recognition in Mobile AppsDeveloping with Speech and Voice Recognition in Mobile Apps
Developing with Speech and Voice Recognition in Mobile AppsNick Landry
 
Speech for Windows Phone 8
Speech for Windows Phone 8Speech for Windows Phone 8
Speech for Windows Phone 8Marco Massarelli
 
Speech for Windows Phone 8
Speech for Windows Phone 8Speech for Windows Phone 8
Speech for Windows Phone 8Appsterdam Milan
 
Ui testing with splinter - Fri, 30 May 2014
Ui testing with splinter - Fri, 30 May 2014Ui testing with splinter - Fri, 30 May 2014
Ui testing with splinter - Fri, 30 May 2014Taizo Ito
 
SumanKAdinarayana_CommandPromptBasics_TipsNTricksPage1_10Apr2022.pdf
SumanKAdinarayana_CommandPromptBasics_TipsNTricksPage1_10Apr2022.pdfSumanKAdinarayana_CommandPromptBasics_TipsNTricksPage1_10Apr2022.pdf
SumanKAdinarayana_CommandPromptBasics_TipsNTricksPage1_10Apr2022.pdfSuman K Adinarayana
 
Intro to PowerShell
Intro to PowerShellIntro to PowerShell
Intro to PowerShellAdam Preston
 
Lev's KC-DC Presentation
Lev's KC-DC PresentationLev's KC-DC Presentation
Lev's KC-DC PresentationLev Ginsburg
 
Code Camp - Presentation - Windows 10 - (Cortana)
Code Camp - Presentation - Windows 10 - (Cortana)Code Camp - Presentation - Windows 10 - (Cortana)
Code Camp - Presentation - Windows 10 - (Cortana)Edward Moemeka
 
Building Windows 10 Universal Apps with Speech and Cortana
Building Windows 10 Universal Apps with Speech and CortanaBuilding Windows 10 Universal Apps with Speech and Cortana
Building Windows 10 Universal Apps with Speech and CortanaNick Landry
 
ITT 2014 - Matt Brenner- Localization 2.0
ITT 2014 - Matt Brenner- Localization 2.0ITT 2014 - Matt Brenner- Localization 2.0
ITT 2014 - Matt Brenner- Localization 2.0Istanbul Tech Talks
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsNathan Smith
 
Managing enterprise with PowerShell remoting
Managing enterprise with PowerShell remotingManaging enterprise with PowerShell remoting
Managing enterprise with PowerShell remotingConcentrated Technology
 

Similar to Hey Cortana! (20)

Beyond Cortana & Siri: Using Speech Recognition & Speech Synthesis for the Ne...
Beyond Cortana & Siri: Using Speech Recognition & Speech Synthesis for the Ne...Beyond Cortana & Siri: Using Speech Recognition & Speech Synthesis for the Ne...
Beyond Cortana & Siri: Using Speech Recognition & Speech Synthesis for the Ne...
 
TDC 2014 - Cortana
TDC 2014 - CortanaTDC 2014 - Cortana
TDC 2014 - Cortana
 
Fonctions vocales sous Windows Phone : intégrez votre application à Cortana !
Fonctions vocales sous Windows Phone : intégrez votre application à Cortana !Fonctions vocales sous Windows Phone : intégrez votre application à Cortana !
Fonctions vocales sous Windows Phone : intégrez votre application à Cortana !
 
Windows Phone 8 - 14 Using Speech
Windows Phone 8 - 14 Using SpeechWindows Phone 8 - 14 Using Speech
Windows Phone 8 - 14 Using Speech
 
Developing with Speech and Voice Recognition in Mobile Apps
Developing with Speech and Voice Recognition in Mobile AppsDeveloping with Speech and Voice Recognition in Mobile Apps
Developing with Speech and Voice Recognition in Mobile Apps
 
Speech for Windows Phone 8
Speech for Windows Phone 8Speech for Windows Phone 8
Speech for Windows Phone 8
 
Speech for Windows Phone 8
Speech for Windows Phone 8Speech for Windows Phone 8
Speech for Windows Phone 8
 
Admin share point with powershell
Admin share point with powershellAdmin share point with powershell
Admin share point with powershell
 
Tml for Laravel
Tml for LaravelTml for Laravel
Tml for Laravel
 
Ui testing with splinter - Fri, 30 May 2014
Ui testing with splinter - Fri, 30 May 2014Ui testing with splinter - Fri, 30 May 2014
Ui testing with splinter - Fri, 30 May 2014
 
SumanKAdinarayana_CommandPromptBasics_TipsNTricksPage1_10Apr2022.pdf
SumanKAdinarayana_CommandPromptBasics_TipsNTricksPage1_10Apr2022.pdfSumanKAdinarayana_CommandPromptBasics_TipsNTricksPage1_10Apr2022.pdf
SumanKAdinarayana_CommandPromptBasics_TipsNTricksPage1_10Apr2022.pdf
 
Intro to PowerShell
Intro to PowerShellIntro to PowerShell
Intro to PowerShell
 
Lev's KC-DC Presentation
Lev's KC-DC PresentationLev's KC-DC Presentation
Lev's KC-DC Presentation
 
PowerShell 8tips
PowerShell 8tipsPowerShell 8tips
PowerShell 8tips
 
Code Camp - Presentation - Windows 10 - (Cortana)
Code Camp - Presentation - Windows 10 - (Cortana)Code Camp - Presentation - Windows 10 - (Cortana)
Code Camp - Presentation - Windows 10 - (Cortana)
 
Building Windows 10 Universal Apps with Speech and Cortana
Building Windows 10 Universal Apps with Speech and CortanaBuilding Windows 10 Universal Apps with Speech and Cortana
Building Windows 10 Universal Apps with Speech and Cortana
 
ITT 2014 - Matt Brenner- Localization 2.0
ITT 2014 - Matt Brenner- Localization 2.0ITT 2014 - Matt Brenner- Localization 2.0
ITT 2014 - Matt Brenner- Localization 2.0
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile Apps
 
April 2010-intro-to-remoting-part2
April 2010-intro-to-remoting-part2April 2010-intro-to-remoting-part2
April 2010-intro-to-remoting-part2
 
Managing enterprise with PowerShell remoting
Managing enterprise with PowerShell remotingManaging enterprise with PowerShell remoting
Managing enterprise with PowerShell remoting
 

More from Mariano Sánchez

Developing Universal Apps for Windows
Developing Universal Apps for WindowsDeveloping Universal Apps for Windows
Developing Universal Apps for WindowsMariano Sánchez
 
Introducing the Windows Phone 8.1 App Development Platform
Introducing the Windows Phone 8.1 App Development PlatformIntroducing the Windows Phone 8.1 App Development Platform
Introducing the Windows Phone 8.1 App Development PlatformMariano Sánchez
 
Universal Windows Platform Programando para todos y todas
Universal Windows PlatformProgramando para todos y todasUniversal Windows PlatformProgramando para todos y todas
Universal Windows Platform Programando para todos y todasMariano Sánchez
 
Refactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteRefactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteMariano Sánchez
 

More from Mariano Sánchez (17)

.NET Core
.NET Core.NET Core
.NET Core
 
ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0
 
Introducción a SignalR
Introducción a SignalRIntroducción a SignalR
Introducción a SignalR
 
Visual Studio LightSwitch
Visual Studio LightSwitchVisual Studio LightSwitch
Visual Studio LightSwitch
 
HTML5 + Asp.NET
HTML5 + Asp.NETHTML5 + Asp.NET
HTML5 + Asp.NET
 
Developing Universal Apps for Windows
Developing Universal Apps for WindowsDeveloping Universal Apps for Windows
Developing Universal Apps for Windows
 
Introducing the Windows Phone 8.1 App Development Platform
Introducing the Windows Phone 8.1 App Development PlatformIntroducing the Windows Phone 8.1 App Development Platform
Introducing the Windows Phone 8.1 App Development Platform
 
Visual Studio Online
Visual Studio OnlineVisual Studio Online
Visual Studio Online
 
Patrones Grasp
Patrones GraspPatrones Grasp
Patrones Grasp
 
Introducción a DDD
Introducción a DDDIntroducción a DDD
Introducción a DDD
 
Conociendo TypeScript
Conociendo TypeScriptConociendo TypeScript
Conociendo TypeScript
 
C# 6 - Que hay de nuevo?
C# 6 - Que hay de nuevo?C# 6 - Que hay de nuevo?
C# 6 - Que hay de nuevo?
 
Universal Windows Platform Programando para todos y todas
Universal Windows PlatformProgramando para todos y todasUniversal Windows PlatformProgramando para todos y todas
Universal Windows Platform Programando para todos y todas
 
Code Smells
Code SmellsCode Smells
Code Smells
 
Introducción a LINQ
Introducción a LINQIntroducción a LINQ
Introducción a LINQ
 
Refactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteRefactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existente
 
Patrones de Diseño
Patrones de DiseñoPatrones de Diseño
Patrones de Diseño
 

Recently uploaded

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 

Recently uploaded (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 

Hey Cortana!

  • 1. Rodolfo Finochietti – Software Architect rodolfof@lagash.com @rodolfof Mariano Sánchez – Software Architect marianos@lagash.com @marianosz
  • 2.
  • 3.
  • 5. Integrate with Cortana in 3 Easy Steps:
  • 6. <?xml version="1.0" encoding="utf-8"?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1"> <CommandSet xml:lang="en-us" Name="englishCommands"> <CommandPrefix>MSDN</CommandPrefix> <Example>How do I add Voice Commands to my application</Example> <Command Name="FindText"> <Example>Find Install Voice Command Sets</Example> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor> <Feedback>Search on MSDN</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <Command Name="nlpCommand"> <Example>How do I add Voice Commands to my application</Example> <ListenFor>{dictatedVoiceCommandText}</ListenFor> <Feedback>Starting MSDN...</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation"> <Subject>MSDN</Subject> </PhraseTopic> <PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject>MSDN</Subject> </PhraseTopic> </CommandSet> </VoiceCommands> Create Voice Command Definition(s)
  • 7. <?xml version="1.0" encoding="utf-8"?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1"> <CommandSet xml:lang="en-us" Name="englishCommands"> <CommandPrefix>MSDN</CommandPrefix> <Example>How do I add Voice Commands to my application</Example> <Command Name="FindText"> <Example>Find Install Voice Command Sets</Example> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor> <Feedback>Search on MSDN</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <Command Name="nlpCommand"> <Example>How do I add Voice Commands to my application</Example> <ListenFor>{dictatedVoiceCommandText}</ListenFor> <Feedback>Starting MSDN...</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation"> <Subject>MSDN</Subject> </PhraseTopic> <PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject>MSDN</Subject> </PhraseTopic> </CommandSet> </VoiceCommands> Create Voice Command Definition(s) <CommandPrefix>MSDN</CommandPrefix>
  • 8. Create Voice Command Definition(s) <?xml version="1.0" encoding="utf-8"?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1"> <CommandSet xml:lang="en-us" Name="englishCommands"> <CommandPrefix>MSDN</CommandPrefix> <Example>How do I add Voice Commands to my application</Example> <Command Name="FindText"> <Example>Find Install Voice Command Sets</Example> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor> <Feedback>Search on MSDN</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <Command Name="nlpCommand"> <Example>How do I add Voice Commands to my application</Example> <ListenFor>{dictatedVoiceCommandText}</ListenFor> <Feedback>Starting MSDN...</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation"> <Subject>MSDN</Subject> </PhraseTopic> <PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject>MSDN</Subject> </PhraseTopic> </CommandSet> </VoiceCommands> <Example>How do I add Voice Commands to my application</Example>
  • 9. <?xml version="1.0" encoding="utf-8"?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1"> <CommandSet xml:lang="en-us" Name="englishCommands"> <CommandPrefix>MSDN</CommandPrefix> <Example>How do I add Voice Commands to my application</Example> <Command Name="FindText"> <Example>Find Install Voice Command Sets</Example> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor> <Feedback>Search on MSDN</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <Command Name="nlpCommand"> <Example>How do I add Voice Commands to my application</Example> <ListenFor>{dictatedVoiceCommandText}</ListenFor> <Feedback>Starting MSDN...</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation"> <Subject>MSDN</Subject> </PhraseTopic> <PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject>MSDN</Subject> </PhraseTopic> </CommandSet> </VoiceCommands> Create Voice Command Definition(s)<Command Name="FindText"> <Example>Find Install Voice Command Sets</Example> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor> <Feedback>Search on MSDN</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <Command Name="nlpCommand"> <Example>How do I add Voice Commands to my application</Example> <ListenFor>{dictatedVoiceCommandText}</ListenFor> <Feedback>Starting MSDN...</Feedback> <Navigate Target="MainPage.xaml" /> /Command>
  • 10. Create Voice Command Definition(s) <?xml version="1.0" encoding="utf-8"?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1"> <CommandSet xml:lang="en-us" Name="englishCommands"> <CommandPrefix>MSDN</CommandPrefix> <Example>How do I add Voice Commands to my application</Example> <Command Name="FindText"> <Example>Find Install Voice Command Sets</Example> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor> <Feedback>Search on MSDN</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <Command Name="nlpCommand"> <Example>How do I add Voice Commands to my application</Example> <ListenFor>{dictatedVoiceCommandText}</ListenFor> <Feedback>Starting MSDN...</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation"> <Subject>MSDN</Subject> </PhraseTopic> <PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject>MSDN</Subject> </PhraseTopic> </CommandSet> </VoiceCommands> <Example>Find Install Voice Command Sets</Example>
  • 11. <?xml version="1.0" encoding="utf-8"?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1"> <CommandSet xml:lang="en-us" Name="englishCommands"> <CommandPrefix>MSDN</CommandPrefix> <Example>How do I add Voice Commands to my application</Example> <Command Name="FindText"> <Example>Find Install Voice Command Sets</Example> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor> <Feedback>Search on MSDN</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <Command Name="nlpCommand"> <Example>How do I add Voice Commands to my application</Example> <ListenFor>{dictatedVoiceCommandText}</ListenFor> <Feedback>Starting MSDN...</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation"> <Subject>MSDN</Subject> </PhraseTopic> <PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject>MSDN</Subject> </PhraseTopic> </CommandSet> </VoiceCommands> Create Voice Command Definition(s) <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor>
  • 12. Create Voice Command Definition(s) <?xml version="1.0" encoding="utf-8"?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1"> <CommandSet xml:lang="en-us" Name="englishCommands"> <CommandPrefix>MSDN</CommandPrefix> <Example>How do I add Voice Commands to my application</Example> <Command Name="FindText"> <Example>Find Install Voice Command Sets</Example> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor> <Feedback>Search on MSDN</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <Command Name="nlpCommand"> <Example>How do I add Voice Commands to my application</Example> <ListenFor>{dictatedVoiceCommandText}</ListenFor> <Feedback>Starting MSDN...</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation"> <Subject>MSDN</Subject> </PhraseTopic> <PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject>MSDN</Subject> </PhraseTopic> </CommandSet> </VoiceCommands> <Feedback>Search on MSDN</Feedback>
  • 13. Create Voice Command Definition(s) <?xml version="1.0" encoding="utf-8"?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1"> <CommandSet xml:lang="en-us" Name="englishCommands"> <CommandPrefix>MSDN</CommandPrefix> <Example>How do I add Voice Commands to my application</Example> <Command Name="FindText"> <Example>Find Install Voice Command Sets</Example> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor> <Feedback>Search on MSDN</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <Command Name="nlpCommand"> <Example>How do I add Voice Commands to my application</Example> <ListenFor>{dictatedVoiceCommandText}</ListenFor> <Feedback>Starting MSDN...</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation"> <Subject>MSDN</Subject> </PhraseTopic> <PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject>MSDN</Subject> </PhraseTopic> </CommandSet> </VoiceCommands> <Navigate Target="MainPage.xaml" />
  • 14. Create Voice Command Definition(s) <?xml version="1.0" encoding="utf-8"?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1"> <CommandSet xml:lang="en-us" Name="englishCommands"> <CommandPrefix>MSDN</CommandPrefix> <Example>How do I add Voice Commands to my application</Example> <Command Name="FindText"> <Example>Find Install Voice Command Sets</Example> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor> <Feedback>Search on MSDN</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <Command Name="nlpCommand"> <Example>How do I add Voice Commands to my application</Example> <ListenFor>{dictatedVoiceCommandText}</ListenFor> <Feedback>Starting MSDN...</Feedback> <Navigate Target="MainPage.xaml" /> </Command> <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation"> <Subject>MSDN</Subject> </PhraseTopic> <PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject>MSDN</Subject> </PhraseTopic> </CommandSet> </VoiceCommands> <PhraseTopic Label="dictatedVoiceCommandText" Scenario="Dictation"> <Subject>MSDN</Subject> </PhraseTopic> <PhraseTopic Label="dictatedSearchTerms" Scenario="Search"> <Subject>MSDN</Subject> </PhraseTopic>
  • 15. private async void // SHOULD BE PERFORMED UNDER TRY/CATCH Uri new ms-appx:///vcd.xml UriKind.Absolute await Windows Phone Silverlight Apps on Windows Phone 8.1 Windows Runtime Apps on Windows Phone 8.1 private async void // SHOULD BE PERFORMED UNDER TRY/CATCH Uri uriVoiceCommands = new Uri("ms-appx:///vcd.xml", UriKind.Absolute); StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(uriVoiceCommands); await VoiceCommandManager.InstallCommandSetsFromStorageFileAsync(file); Register VCD XML file on App Startup
  • 16. Handle Voice Command Activation ❶ ❷ ❸
  • 17. // Windows Runtime App on Windows Phone 8.1, inside OnActivated override in App class if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args; string voiceCommandName = vcArgs.Result.RulePath.First(); // What command launched the app? switch (voiceCommandName) // Navigate to right page for the voice command { case "FindText": // User said "find" or "search" rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result); break; case "nlpCommand": // User said something else rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result); break; } } Handle Voice Command Activation
  • 18. // Windows Runtime App on Windows Phone 8.1, inside OnActivated override in App class if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args; string voiceCommandName = vcArgs.Result.RulePath.First(); // What command launched the app? switch (voiceCommandName) // Navigate to right page for the voice command { case "FindText": // User said "find" or "search" rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result); break; case "nlpCommand": // User said something else rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result); break; } } Handle Voice Command Activation // Windows Runtime App on Windows Phone 8.1, inside OnActivated override // in App class if (args.Kind == ActivationKind.VoiceCommand)
  • 19. // Windows Runtime App on Windows Phone 8.1, inside OnActivated override in App class if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args; string voiceCommandName = vcArgs.Result.RulePath.First(); // What command launched the app? switch (voiceCommandName) // Navigate to right page for the voice command { case "FindText": // User said "find" or "search" rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result); break; case "nlpCommand": // User said something else rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result); break; } } Handle Voice Command Activation VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args; // What command launched the app? string voiceCommandName = vcArgs.Result.RulePath.First(); // Navigate to right page for the voice command switch (voiceCommandName)
  • 20. // Windows Runtime App on Windows Phone 8.1, inside OnActivated override in App class if (args.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs vcArgs = (VoiceCommandActivatedEventArgs)args; string voiceCommandName = vcArgs.Result.RulePath.First(); // What command launched the app? switch (voiceCommandName) // Navigate to right page for the voice command { case "FindText": // User said "find" or "search" rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result); break; case "nlpCommand": // User said something else rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result); break; } } Handle Voice Command Activation // Navigate to right page for the voice command switch (voiceCommandName) { case "FindText": // User said "find" or "search" rootFrame.Navigate(typeof(MSDN.FindText), vcArgs.Result); break; case "nlpCommand": // User said something else rootFrame.Navigate(typeof(MSDN.NlpCommand), vcArgs.Result); break; }
  • 21. // Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo in FindText.xaml.cs protected override void OnNavigatedTo(NavigationEventArgs e) { // Get recognition result from parameter passed in frame.Navigate call SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult; if (vcResult!=null) { // What did the user say? e.g. MSDN, "Find Windows Phone Voice Commands" string recoText = vcResult.Text; // Store the semantics dictionary for later use IReadOnlyDictionary<string,IReadOnlyList<string>> semantics = vcResult.SemanticInterpretation.Properties; string voiceCommandName = vcResult.RulePath.First(); if (voiceCommandName == "FindText") { // What did the user say, for named phrase topic or list "slots"? e.g. "Windows Phone Voice Commands" if (semantics.ContainsKey("dictatedSearchTerms")) { HandleFindTextWithSearchTerms(semantics["dictatedSearchTerms"][0]); } else { HandleNoSearchTerms(); } } // Else handle other voice commands } navigationHelper.OnNavigatedTo(e) Handle Voice Command Activation
  • 22. // Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo In FindText.xaml.cs protected override void OnNavigatedTo(NavigationEventArgs e) { // Get recognition result from parameter passed in frame.Navigate call SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult; if (vcResult!=null) { // What did the user say? e.g. MSDN, "Find Windows Phone Voice Commands" string recoText = vcResult.Text; // Store the semantics dictionary for later use IReadOnlyDictionary<string,IReadOnlyList<string>> semantics = vcResult.SemanticInterpretation.Properties; string voiceCommandName = vcResult.RulePath.First(); if (voiceCommandName == "FindText") { // What did the user say, for named phrase topic or list "slots"? e.g. "Windows Phone Voice Commands" if (semantics.ContainsKey("dictatedSearchTerms")) { HandleFindTextWithSearchTerms(semantics["dictatedSearchTerms"][0]); } else { HandleNoSearchTerms(); } } // Else handle other voice commands } navigationHelper.OnNavigatedTo(e) Handle Voice Command Activation // Windows Runtime App on Windows Phone 8.1, inside // OnNavigatedTo in FindText.xaml.cs protected override void OnNavigatedTo(NavigationEventArgs e) { // Get recognition result from parameter passed in frame.Navigate call SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult; if (vcResult!=null) { // What did the user say? e.g. MSDN, "Find Windows Phone Voice Commands" string recoText = vcResult.Text; // Store the semantics dictionary for later use IReadOnlyDictionary<string,IReadOnlyList<string>> semantics = vcResult.SemanticInterpretation.Properties; string voiceCommandName = vcResult.RulePath.First();
  • 23. // Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo In FindText.xaml.cs protected override void OnNavigatedTo(NavigationEventArgs e) { // Get recognition result from parameter passed in frame.Navigate call SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult; if (vcResult!=null) { // What did the user say? e.g. MSDN, "Find Windows Phone Voice Commands" string recoText = vcResult.Text; // Store the semantics dictionary for later use IReadOnlyDictionary<string,IReadOnlyList<string>> semantics = vcResult.SemanticInterpretation.Properties; string voiceCommandName = vcResult.RulePath.First(); if (voiceCommandName == "FindText") { // What did the user say, for named phrase topic or list "slots"? e.g. "Windows Phone Voice Commands" if (semantics.ContainsKey("dictatedSearchTerms")) { HandleFindTextWithSearchTerms(semantics["dictatedSearchTerms"][0]); } else { HandleNoSearchTerms(); } } // Else handle other voice commands } navigationHelper.OnNavigatedTo(e) } Handle Voice Command Activation if (voiceCommandName == "FindText") { // What did the user say, for named phrase topic or list "slots"? // e.g. "Windows Phone Voice Commands" if (semantics.ContainsKey("dictatedSearchTerms")) { HandleFindTextWithSearchTerms(semantics["dictatedSearchTerms"][0]); } else { HandleNoSearchTerms(); } }
  • 24. // Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo in NlpCommand.xaml.cs protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); // Get recognition result from parameter passed in frame.Navigate call SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult; // Check for null! string commandMode = vcResult.SemanticInterpretation.Properties["commandMode"][0]; if (commandMode == "voice") // Did the user speak or type the command? { SpeakText(audioPlayer, String.Format("MSDN app heard you say {0}", vcResult.Text)); HandleNlpCommand(vcResult); } else if(commandMode=="text") { messageTextBox.Text = string.Format("Working on your request "{0}"", vcResult.Text); HandleNlpCommand(vcResult); } } Handle Voice Command Activation
  • 25. // Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo In NlpCommand.xaml.cs protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); // Get recognition result from parameter passed in frame.Navigate call SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult; // Check for null! string commandMode = vcResult.SemanticInterpretation.Properties["commandMode"][0]; if (commandMode == "voice") // Did the user speak or type the command? { SpeakText(audioPlayer, String.Format("MSDN app heard you say {0}", vcResult.Text)); HandleNlpCommand(vcResult); } else if(commandMode=="text") { messageTextBox.Text = string.Format("Working on your request "{0}"", vcResult.Text); HandleNlpCommand(vcResult); } } Handle Voice Command Activation // Windows Runtime App on Windows Phone 8.1, in OnNavigatedTo in NlpCommand.xaml.cs protected override void OnNavigatedTo(NavigationEventArgs e) { // Get recognition result from parameter passed in frame.Navigate call SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult; string commandMode = vcResult.SemanticInterpretation.Properties["commandMode"][0];
  • 26. // Windows Runtime App on Windows Phone 8.1, inside OnNavigatedTo In NlpCommand.xaml.cs protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); // Get recognition result from parameter passed in frame.Navigate call SpeechRecognitionResult vcResult = e.Parameter as SpeechRecognitionResult; // Check for null! string commandMode = vcResult.SemanticInterpretation.Properties["commandMode"][0]; if (commandMode == "voice") // Did the user speak or type the command? { SpeakText(audioPlayer, String.Format("MSDN app heard you say {0}", vcResult.Text)); HandleNlpCommand(vcResult); } else if(commandMode=="text") { messageTextBox.Text = string.Format("Working on your request "{0}"", vcResult.Text); HandleNlpCommand(vcResult); } } Handle string commandMode = vcResult.SemanticInterpretation.Properties["commandMode"][0]; if (commandMode == "voice") // Did the user speak or type the command? { SpeakText(audioPlayer, String.Format("MSDN voice heard you say {0}", vcResult.Text)); HandleNlpCommand(vcResult); } else if(commandMode=="text") { msgTextBox.Text= string.Format("Working on your request "{0}"", vcResult.Text); HandleNlpCommand(vcResult); }
  • 27.
  • 28. Muchas Gracias Rodolfo Finochietti – Software Architect rodolfof@lagash.com @rodolfof Mariano Sánchez – Software Architect marianos@lagash.com @marianosz