You can integrate Cortana into your application:
Creating Voice Command Definitions (VCD)
<?xml version="1.0" encoding="utf-8" ?> <VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.1"> <CommandSet xml:lang="en-us" Name="HomeControlCommandSet_en-us"> <CommandPrefix>HomeControl</CommandPrefix> <Example>Control alarm, temperature, light and others</Example> <Command Name="Activate_Alarm"> <Example>Activate alarm</Example> <ListenFor>[Would] [you] [please] activate [the] alarm [please]</ListenFor> <ListenFor RequireAppName="BeforeOrAfterPhrase">Activate alarm</ListenFor> <Feedback>Activating alarm</Feedback> <Navigate /> </Command> <Command Name="Change_Temperature"> <Example>Change temperature to 25ΒΊ degrees</Example> <ListenFor>Change temperature to {temperature} degrees</ListenFor> <Feedback>Changing temperature to {temperature} degrees</Feedback> <Navigate /> </Command> <Command Name="Change_Light_Color"> <Example>Change light color to yellow</Example> <ListenFor>Change light color to {colors}</ListenFor> <Feedback>Changing light color to {colors}</Feedback> <Navigate /> </Command> <PhraseList Label="colors"> <Item>yellow</Item> <Item>green</Item> <Item>red</Item> </PhraseList> <PhraseTopic Label="temperature"> </PhraseTopic> </CommandSet> </VoiceCommands>
VCD registration on App launch
StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"HomeControlCommands.xml"); await VoiceCommandManager.InstallCommandSetsFromStorageFileAsync(vcdStorageFile);
Command processing
protected override void OnActivated(IActivatedEventArgs e) { // Handle when app is launched by Cortana if (e.Kind == ActivationKind.VoiceCommand) { VoiceCommandActivatedEventArgs commandArgs = e as VoiceCommandActivatedEventArgs; SpeechRecognitionResult speechRecognitionResult = commandArgs.Result; string voiceCommandName = speechRecognitionResult.RulePath[0]; string textSpoken = speechRecognitionResult.Text; IReadOnlyList<string> recognizedVoiceCommandPhrases; System.Diagnostics.Debug.WriteLine("voiceCommandName: " + voiceCommandName); System.Diagnostics.Debug.WriteLine("textSpoken: " + textSpoken); switch (voiceCommandName) ... }
Further information can be found at http://talkitbr.com/2015/07/13/integrando-a-cortana-em-seu-aplicativo-windows-10/
Also, if you are interested in answering the user through the Cortana window, check this box for Cortana in the background.
talkitbr
source share