SlideShare a Scribd company logo
Cortana 
CartujaDotNet 
Integrando nuestra 
aplicación Windows 
Phone con Cortana
Microsoft MVP Windows Platform Development 
• Blog: http://geeks.ms/blogs/jsuarez 
• Email: javiersuarezruiz@hotmail.com 
• Twitter: @jsuarezruiz
<?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>
<?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> 
<CommandPrefix>MSDN</CommandPrefix>
<?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> 
<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>
<?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> 
<ListenFor>Search</ListenFor> 
<ListenFor>Search for {dictatedSearchTerms}</ListenFor> 
<ListenFor>Find</ListenFor> 
<ListenFor>Find {dictatedSearchTerms}</ListenFor>
<?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>
<?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" />
<?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>
<?xml version="1.0" encoding="utf-8"?> 
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.0"> 
<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>
Windows Phone Silverlight Apps 
private async void 
// SHOULD BE PERFORMED UNDER TRY/CATCH 
Uri new ms-appx:///vcd.xml UriKind.Absolute 
await 
Windows Runtime Apps 
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);
❶ 
❷ 
❸
// 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; 
} 
}
// 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; 
} 
} 
// 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; 
} 
} 
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; 
} 
} 
// 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) 
}
// 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) 
} 
// 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 Phone Store App 
// Recognition 
private async Task<SpeechRecognitionResult> RecognizeSpeech() 
{ 
SpeechRecognizer recognizer = new SpeechRecognizer(); 
// One of three Constraint types available 
SpeechRecognitionTopicConstraint topicConstraint 
= new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.WebSearch, "MSDN"); 
recognizer.Constraints.Add(topicConstraint); 
await recognizer.CompileConstraintsAsync(); // Required 
// Put up UI and recognize user's utterance 
SpeechRecognitionResult result = await recognizer.RecognizeWithUIAsync(); 
return result; 
} 
// Calling code uses result.RecognitionResult.Text or 
// result.RecognitionResult.SemanticInterpretation
SpeechRecognizer recognizer = new SpeechRecognizer(); 
// Windows Phone Store App 
// One of three Constraint types available 
SpeechRecognitionTopicConstraint topicConstraint 
// Recognition 
private async Task<SpeechRecognitionResult> RecognizeSpeech() 
{ 
= new SpeechRecognitionTopicConstraint( 
SpeechRecognitionScenario.WebSearch, "MSDN"); 
SpeechRecognizer recognizer = new SpeechRecognizer(); 
// One of three Constraint types available 
SpeechRecognitionTopicConstraint topicConstraint 
recognizer.Constraints.Add(topicConstraint); 
= new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.WebSearch, "MSDN"); 
await recognizer.CompileConstraintsAsync(); // Requerido 
recognizer.Constraints.Add(topicConstraint); 
await recognizer.CompileConstraintsAsync(); // Required 
// Put up UI and recognize user's utterance 
SpeechRecognitionResult result = await recognizer.RecognizeWithUIAsync(); 
return result; 
} 
// Calling code uses result.RecognitionResult.Text or 
// result.RecognitionResult.SemanticInterpretation
// Windows Phone Store App 
// Put up UI and recognize user's utterance 
SpeechRecognitionResult result 
// Recognition 
private async Task<SpeechRecognitionResult> RecognizeSpeech() 
{ 
= await recognizer.RecognizeWithUIAsync(); 
SpeechRecognizer recognizer = new SpeechRecognizer(); 
return result; 
// One of three Constraint types available 
SpeechRecognitionTopicConstraint topicConstraint 
} 
// Calling code uses result.RecognitionResult.Text or 
// result.RecognitionResult.SemanticInterpretation 
= new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.WebSearch, "MSDN"); 
recognizer.Constraints.Add(topicConstraint); 
await recognizer.CompileConstraintsAsync(); // Required 
// Put up UI and recognize user's utterance 
SpeechRecognitionResult result = await recognizer.RecognizeWithUIAsync(); 
return result; 
} 
// Calling code uses result.RecognitionResult.Text or 
// result.RecognitionResult.SemanticInterpretation
Preguntas y respuestas. 
¿Dudas? 
&
Gracias por vuestro tiempo! 
Integrando nuestra 
AplicaciónWindows 
Phone con Cortana

More Related Content

Similar to Integrando nuestra Aplicación Windows Phone con 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 !
Microsoft
 
Windows Phone 8 - 14 Using Speech
Windows Phone 8 - 14 Using SpeechWindows Phone 8 - 14 Using Speech
Windows Phone 8 - 14 Using Speech
Oliver 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 Apps
Nick Landry
 
Speech for Windows Phone 8
Speech for Windows Phone 8Speech for Windows Phone 8
Speech for Windows Phone 8
Marco Massarelli
 
Speech for Windows Phone 8
Speech for Windows Phone 8Speech for Windows Phone 8
Speech for Windows Phone 8
Appsterdam Milan
 
Selenium tutorial
Selenium tutorialSelenium tutorial
Selenium tutorial
mindqqa
 
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
Nathan Smith
 
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStartBest Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
Scott DeLoach
 
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
Taizo Ito
 
PowerShell 8tips
PowerShell 8tipsPowerShell 8tips
PowerShell 8tips
Concentrated Technology
 
SmokeTests - What, Why & How - ConFoo 2019
SmokeTests - What, Why & How - ConFoo 2019SmokeTests - What, Why & How - ConFoo 2019
SmokeTests - What, Why & How - ConFoo 2019
tech.kartenmacherei
 
Selenium Open Source Tool
Selenium Open Source ToolSelenium Open Source Tool
Selenium Open Source Tool
onlinemindq
 
Selenium.ppt
Selenium.pptSelenium.ppt
Selenium.ppt
onlinemindq
 
Admin share point with powershell
Admin share point with powershellAdmin share point with powershell
Admin share point with powershell
Concentrated Technology
 
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
実例で学ぶ、明日から使えるSpring Boot Tips #jsug実例で学ぶ、明日から使えるSpring Boot Tips #jsug
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
Toshiaki Maki
 
KE User Group 2011 showcase: WordPress integration
KE User Group 2011 showcase: WordPress integrationKE User Group 2011 showcase: WordPress integration
KE User Group 2011 showcase: WordPress integration
Paul Trafford
 
Android search
Android searchAndroid search
Android search
Krazy Koder
 
Android search
Android searchAndroid search
Android search
Krazy Koder
 
April 2010-intro-to-remoting-part2
April 2010-intro-to-remoting-part2April 2010-intro-to-remoting-part2
April 2010-intro-to-remoting-part2
Southeast Michigan PowerShell Script Club
 
Siteocre Sxa and Solr - Sitecore User Group UAE Dubai- Jitendra Soni
Siteocre Sxa and Solr - Sitecore User Group UAE Dubai- Jitendra SoniSiteocre Sxa and Solr - Sitecore User Group UAE Dubai- Jitendra Soni
Siteocre Sxa and Solr - Sitecore User Group UAE Dubai- Jitendra Soni
Jitendra Soni
 

Similar to Integrando nuestra Aplicación Windows Phone con Cortana (20)

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
 
Selenium tutorial
Selenium tutorialSelenium tutorial
Selenium tutorial
 
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
 
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStartBest Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
Best Practices for Embedded UA - WritersUA 2012, Scott DeLoach, ClickStart
 
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
 
PowerShell 8tips
PowerShell 8tipsPowerShell 8tips
PowerShell 8tips
 
SmokeTests - What, Why & How - ConFoo 2019
SmokeTests - What, Why & How - ConFoo 2019SmokeTests - What, Why & How - ConFoo 2019
SmokeTests - What, Why & How - ConFoo 2019
 
Selenium Open Source Tool
Selenium Open Source ToolSelenium Open Source Tool
Selenium Open Source Tool
 
Selenium.ppt
Selenium.pptSelenium.ppt
Selenium.ppt
 
Admin share point with powershell
Admin share point with powershellAdmin share point with powershell
Admin share point with powershell
 
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
実例で学ぶ、明日から使えるSpring Boot Tips #jsug実例で学ぶ、明日から使えるSpring Boot Tips #jsug
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
 
KE User Group 2011 showcase: WordPress integration
KE User Group 2011 showcase: WordPress integrationKE User Group 2011 showcase: WordPress integration
KE User Group 2011 showcase: WordPress integration
 
Android search
Android searchAndroid search
Android search
 
Android search
Android searchAndroid search
Android search
 
April 2010-intro-to-remoting-part2
April 2010-intro-to-remoting-part2April 2010-intro-to-remoting-part2
April 2010-intro-to-remoting-part2
 
Siteocre Sxa and Solr - Sitecore User Group UAE Dubai- Jitendra Soni
Siteocre Sxa and Solr - Sitecore User Group UAE Dubai- Jitendra SoniSiteocre Sxa and Solr - Sitecore User Group UAE Dubai- Jitendra Soni
Siteocre Sxa and Solr - Sitecore User Group UAE Dubai- Jitendra Soni
 

More from Javier Suárez Ruiz

Cape Town MS Developer User Group: Xamarin Community Toolkit
Cape Town MS Developer User Group: Xamarin Community ToolkitCape Town MS Developer User Group: Xamarin Community Toolkit
Cape Town MS Developer User Group: Xamarin Community Toolkit
Javier Suárez Ruiz
 
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de XamarinDotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
Javier Suárez Ruiz
 
Tech Club Asturias: Un vistazo al presente y futuro de Xamarin.Forms
Tech Club Asturias: Un vistazo al presente y futuro de Xamarin.FormsTech Club Asturias: Un vistazo al presente y futuro de Xamarin.Forms
Tech Club Asturias: Un vistazo al presente y futuro de Xamarin.Forms
Javier Suárez Ruiz
 
Monkey Conf 2020: Xamarin Community Toolkit: More possibilities with Xamarin....
Monkey Conf 2020: Xamarin Community Toolkit: More possibilities with Xamarin....Monkey Conf 2020: Xamarin Community Toolkit: More possibilities with Xamarin....
Monkey Conf 2020: Xamarin Community Toolkit: More possibilities with Xamarin....
Javier Suárez Ruiz
 
Monkey Conf 2020: .NET MAUI Handlers
Monkey Conf 2020: .NET MAUI HandlersMonkey Conf 2020: .NET MAUI Handlers
Monkey Conf 2020: .NET MAUI Handlers
Javier Suárez Ruiz
 
Creando controles para Xamarin.Forms
Creando controles para Xamarin.FormsCreando controles para Xamarin.Forms
Creando controles para Xamarin.Forms
Javier Suárez Ruiz
 
Monkey Conf 2019: Presente y futuro de Xamarin.Forms
Monkey Conf 2019: Presente y futuro de Xamarin.FormsMonkey Conf 2019: Presente y futuro de Xamarin.Forms
Monkey Conf 2019: Presente y futuro de Xamarin.Forms
Javier Suárez Ruiz
 
Crear interfaces de usuario atractivas con Xamarin.Forms
Crear interfaces de usuario atractivas con Xamarin.FormsCrear interfaces de usuario atractivas con Xamarin.Forms
Crear interfaces de usuario atractivas con Xamarin.Forms
Javier Suárez Ruiz
 
#XamarinUIJuly Summary
#XamarinUIJuly Summary#XamarinUIJuly Summary
#XamarinUIJuly Summary
Javier Suárez Ruiz
 
DotNet 2019: Optimizando Apps con Xamarin.Forms
DotNet 2019: Optimizando Apps con Xamarin.FormsDotNet 2019: Optimizando Apps con Xamarin.Forms
DotNet 2019: Optimizando Apps con Xamarin.Forms
Javier Suárez Ruiz
 
Taller Xamarin Monkey Conf 2018
Taller Xamarin Monkey Conf 2018Taller Xamarin Monkey Conf 2018
Taller Xamarin Monkey Conf 2018
Javier Suárez Ruiz
 
Monkey Conf 2018: Conociendo Xamarin.Forms Shell
Monkey Conf 2018: Conociendo Xamarin.Forms ShellMonkey Conf 2018: Conociendo Xamarin.Forms Shell
Monkey Conf 2018: Conociendo Xamarin.Forms Shell
Javier Suárez Ruiz
 
.Net Conf Sevilla 2018
.Net Conf Sevilla 2018.Net Conf Sevilla 2018
.Net Conf Sevilla 2018
Javier Suárez Ruiz
 
Analizando interfaces de usuario avanzadas con Xamarin.Forms
Analizando interfaces de usuario avanzadas con Xamarin.FormsAnalizando interfaces de usuario avanzadas con Xamarin.Forms
Analizando interfaces de usuario avanzadas con Xamarin.Forms
Javier Suárez Ruiz
 
OpenSouthCode 2018: Taller Xamarin
OpenSouthCode 2018: Taller XamarinOpenSouthCode 2018: Taller Xamarin
OpenSouthCode 2018: Taller Xamarin
Javier Suárez Ruiz
 
DotNet2018: Xamarin.Forms Everywhere!
DotNet2018: Xamarin.Forms Everywhere!DotNet2018: Xamarin.Forms Everywhere!
DotNet2018: Xamarin.Forms Everywhere!
Javier Suárez Ruiz
 
Novedades Xamarin 3.0 Preview
Novedades Xamarin 3.0 PreviewNovedades Xamarin 3.0 Preview
Novedades Xamarin 3.0 Preview
Javier Suárez Ruiz
 
Desarrollo Xamarin, más allá del desarrollo
Desarrollo Xamarin, más allá del desarrolloDesarrollo Xamarin, más allá del desarrollo
Desarrollo Xamarin, más allá del desarrollo
Javier Suárez Ruiz
 
Introducción a Xamarin.Forms
Introducción a Xamarin.FormsIntroducción a Xamarin.Forms
Introducción a Xamarin.Forms
Javier Suárez Ruiz
 
Introducción a Xamarin
Introducción a XamarinIntroducción a Xamarin
Introducción a Xamarin
Javier Suárez Ruiz
 

More from Javier Suárez Ruiz (20)

Cape Town MS Developer User Group: Xamarin Community Toolkit
Cape Town MS Developer User Group: Xamarin Community ToolkitCape Town MS Developer User Group: Xamarin Community Toolkit
Cape Town MS Developer User Group: Xamarin Community Toolkit
 
DotNetDom: El futuro de Xamarin
DotNetDom: El futuro de XamarinDotNetDom: El futuro de Xamarin
DotNetDom: El futuro de Xamarin
 
Tech Club Asturias: Un vistazo al presente y futuro de Xamarin.Forms
Tech Club Asturias: Un vistazo al presente y futuro de Xamarin.FormsTech Club Asturias: Un vistazo al presente y futuro de Xamarin.Forms
Tech Club Asturias: Un vistazo al presente y futuro de Xamarin.Forms
 
Monkey Conf 2020: Xamarin Community Toolkit: More possibilities with Xamarin....
Monkey Conf 2020: Xamarin Community Toolkit: More possibilities with Xamarin....Monkey Conf 2020: Xamarin Community Toolkit: More possibilities with Xamarin....
Monkey Conf 2020: Xamarin Community Toolkit: More possibilities with Xamarin....
 
Monkey Conf 2020: .NET MAUI Handlers
Monkey Conf 2020: .NET MAUI HandlersMonkey Conf 2020: .NET MAUI Handlers
Monkey Conf 2020: .NET MAUI Handlers
 
Creando controles para Xamarin.Forms
Creando controles para Xamarin.FormsCreando controles para Xamarin.Forms
Creando controles para Xamarin.Forms
 
Monkey Conf 2019: Presente y futuro de Xamarin.Forms
Monkey Conf 2019: Presente y futuro de Xamarin.FormsMonkey Conf 2019: Presente y futuro de Xamarin.Forms
Monkey Conf 2019: Presente y futuro de Xamarin.Forms
 
Crear interfaces de usuario atractivas con Xamarin.Forms
Crear interfaces de usuario atractivas con Xamarin.FormsCrear interfaces de usuario atractivas con Xamarin.Forms
Crear interfaces de usuario atractivas con Xamarin.Forms
 
#XamarinUIJuly Summary
#XamarinUIJuly Summary#XamarinUIJuly Summary
#XamarinUIJuly Summary
 
DotNet 2019: Optimizando Apps con Xamarin.Forms
DotNet 2019: Optimizando Apps con Xamarin.FormsDotNet 2019: Optimizando Apps con Xamarin.Forms
DotNet 2019: Optimizando Apps con Xamarin.Forms
 
Taller Xamarin Monkey Conf 2018
Taller Xamarin Monkey Conf 2018Taller Xamarin Monkey Conf 2018
Taller Xamarin Monkey Conf 2018
 
Monkey Conf 2018: Conociendo Xamarin.Forms Shell
Monkey Conf 2018: Conociendo Xamarin.Forms ShellMonkey Conf 2018: Conociendo Xamarin.Forms Shell
Monkey Conf 2018: Conociendo Xamarin.Forms Shell
 
.Net Conf Sevilla 2018
.Net Conf Sevilla 2018.Net Conf Sevilla 2018
.Net Conf Sevilla 2018
 
Analizando interfaces de usuario avanzadas con Xamarin.Forms
Analizando interfaces de usuario avanzadas con Xamarin.FormsAnalizando interfaces de usuario avanzadas con Xamarin.Forms
Analizando interfaces de usuario avanzadas con Xamarin.Forms
 
OpenSouthCode 2018: Taller Xamarin
OpenSouthCode 2018: Taller XamarinOpenSouthCode 2018: Taller Xamarin
OpenSouthCode 2018: Taller Xamarin
 
DotNet2018: Xamarin.Forms Everywhere!
DotNet2018: Xamarin.Forms Everywhere!DotNet2018: Xamarin.Forms Everywhere!
DotNet2018: Xamarin.Forms Everywhere!
 
Novedades Xamarin 3.0 Preview
Novedades Xamarin 3.0 PreviewNovedades Xamarin 3.0 Preview
Novedades Xamarin 3.0 Preview
 
Desarrollo Xamarin, más allá del desarrollo
Desarrollo Xamarin, más allá del desarrolloDesarrollo Xamarin, más allá del desarrollo
Desarrollo Xamarin, más allá del desarrollo
 
Introducción a Xamarin.Forms
Introducción a Xamarin.FormsIntroducción a Xamarin.Forms
Introducción a Xamarin.Forms
 
Introducción a Xamarin
Introducción a XamarinIntroducción a Xamarin
Introducción a Xamarin
 

Integrando nuestra Aplicación Windows Phone con Cortana

  • 1. Cortana CartujaDotNet Integrando nuestra aplicación Windows Phone con Cortana
  • 2. Microsoft MVP Windows Platform Development • Blog: http://geeks.ms/blogs/jsuarez • Email: javiersuarezruiz@hotmail.com • Twitter: @jsuarezruiz
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. <?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>
  • 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> <CommandPrefix>MSDN</CommandPrefix>
  • 10. <?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>
  • 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> <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>
  • 12. <?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>
  • 13. <?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> <ListenFor>Search</ListenFor> <ListenFor>Search for {dictatedSearchTerms}</ListenFor> <ListenFor>Find</ListenFor> <ListenFor>Find {dictatedSearchTerms}</ListenFor>
  • 14. <?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>
  • 15. <?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" />
  • 16. <?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>
  • 17.
  • 18. <?xml version="1.0" encoding="utf-8"?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.0"> <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>
  • 19. Windows Phone Silverlight Apps private async void // SHOULD BE PERFORMED UNDER TRY/CATCH Uri new ms-appx:///vcd.xml UriKind.Absolute await Windows Runtime Apps 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);
  • 20.
  • 22. // 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; } }
  • 23. // 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; } } // Windows Runtime App on Windows Phone 8.1, inside OnActivated override // in App class if (args.Kind == ActivationKind.VoiceCommand)
  • 24. // 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; } } 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)
  • 25. // 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; } } // 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; }
  • 26. // 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) }
  • 27. // 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) } // 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();
  • 28.
  • 30. ❶ ❷ ❸
  • 31.
  • 32. // Windows Phone Store App // Recognition private async Task<SpeechRecognitionResult> RecognizeSpeech() { SpeechRecognizer recognizer = new SpeechRecognizer(); // One of three Constraint types available SpeechRecognitionTopicConstraint topicConstraint = new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.WebSearch, "MSDN"); recognizer.Constraints.Add(topicConstraint); await recognizer.CompileConstraintsAsync(); // Required // Put up UI and recognize user's utterance SpeechRecognitionResult result = await recognizer.RecognizeWithUIAsync(); return result; } // Calling code uses result.RecognitionResult.Text or // result.RecognitionResult.SemanticInterpretation
  • 33. SpeechRecognizer recognizer = new SpeechRecognizer(); // Windows Phone Store App // One of three Constraint types available SpeechRecognitionTopicConstraint topicConstraint // Recognition private async Task<SpeechRecognitionResult> RecognizeSpeech() { = new SpeechRecognitionTopicConstraint( SpeechRecognitionScenario.WebSearch, "MSDN"); SpeechRecognizer recognizer = new SpeechRecognizer(); // One of three Constraint types available SpeechRecognitionTopicConstraint topicConstraint recognizer.Constraints.Add(topicConstraint); = new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.WebSearch, "MSDN"); await recognizer.CompileConstraintsAsync(); // Requerido recognizer.Constraints.Add(topicConstraint); await recognizer.CompileConstraintsAsync(); // Required // Put up UI and recognize user's utterance SpeechRecognitionResult result = await recognizer.RecognizeWithUIAsync(); return result; } // Calling code uses result.RecognitionResult.Text or // result.RecognitionResult.SemanticInterpretation
  • 34. // Windows Phone Store App // Put up UI and recognize user's utterance SpeechRecognitionResult result // Recognition private async Task<SpeechRecognitionResult> RecognizeSpeech() { = await recognizer.RecognizeWithUIAsync(); SpeechRecognizer recognizer = new SpeechRecognizer(); return result; // One of three Constraint types available SpeechRecognitionTopicConstraint topicConstraint } // Calling code uses result.RecognitionResult.Text or // result.RecognitionResult.SemanticInterpretation = new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.WebSearch, "MSDN"); recognizer.Constraints.Add(topicConstraint); await recognizer.CompileConstraintsAsync(); // Required // Put up UI and recognize user's utterance SpeechRecognitionResult result = await recognizer.RecognizeWithUIAsync(); return result; } // Calling code uses result.RecognitionResult.Text or // result.RecognitionResult.SemanticInterpretation
  • 35.
  • 37. Gracias por vuestro tiempo! Integrando nuestra AplicaciónWindows Phone con Cortana