hands free with cortana

Post on 22-Jan-2018

57 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Handsfree with Cortana

“I’m Fiyaz Hasan

#Versatile #Tech #Developer

I’m a .NET and JavaScript enthusiast. I like to work with

different technologies on different platforms. I love the

logic and structure of coding and always strives to write

more elegant and efficient code. I’m passionate about

design patterns and applying Software Engineering best

practices.

www.fiyazhasan.me

Hey Cortana, Who am I?

You are Fizz

Hey Cortana, Who are you?

I am Cortana

Integrating with Cortana in 3 simple steps

Create Voice Command

Definition (s)Register VCD on

App StartupHandle Voice

Command Activation

CREATING VOICE COMMAND DEFINATION(S)

Step 1

<?xml version="1.0" encoding="utf-8"?>

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

<CommandSet xml:lang="en-us" Name="MySimpleTodoCommandSet_en-us">

<CommandPrefix> My Simple To do </CommandPrefix>

<Example> pending tasks </Example>

<Command Name="todoBackgroundCommandList">

<Example> pending tasks </Example>

<ListenFor> {command} task[s] </ListenFor>

<Feedback> Executing specific command </Feedback>

<VoiceCommandService Target="SimpleTodoVoiceCommandService"/>

</Command>

<PhraseTopic Label="command" Scenario="Search">

<Subject> pending </Subject>

</PhraseTopic>

</CommandSet>

</VoiceCommands>

Create Voice Command Definition(s)

Note: the VCD is identical for JavaScript and C# apps

<?xml version="1.0" encoding="utf-8"?>

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

<CommandSet xml:lang="en-us" Name="MySimpleTodoCommandSet_en-us">

<CommandPrefix> My Simple To do </CommandPrefix>

<Example> pending tasks </Example>

<Command Name="todoBackgroundCommandList">

<Example> pending tasks </Example>

<ListenFor> {command} task[s] </ListenFor>

<Feedback> Executing specific command </Feedback>

<VoiceCommandService Target="SimpleTodoVoiceCommandService"/>

</Command>

<PhraseTopic Label="command" Scenario="Search">

<Subject> pending </Subject>

</PhraseTopic>

</CommandSet>

</VoiceCommands>

<CommandPrefix> My Simple To do </CommandPrefix>

Step 1

<?xml version="1.0" encoding="utf-8"?>

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

<CommandSet xml:lang="en-us" Name="MySimpleTodoCommandSet_en-us">

<CommandPrefix> My Simple To do </CommandPrefix>

<Example> pending tasks </Example>

<Command Name="todoBackgroundCommandList">

<Example> pending tasks </Example>

<ListenFor> {command} task[s] </ListenFor>

<Feedback> Executing specific command </Feedback>

<VoiceCommandService Target="SimpleTodoVoiceCommandService"/>

</Command>

<PhraseTopic Label="command" Scenario="Search">

<Subject> pending </Subject>

</PhraseTopic>

</CommandSet>

</VoiceCommands>

<Example> pending tasks </Example>

Step 1

<?xml version="1.0" encoding="utf-8"?>

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

<CommandSet xml:lang="en-us" Name="MySimpleTodoCommandSet_en-us">

<CommandPrefix> My Simple To do </CommandPrefix>

<Example> pending tasks </Example>

<Command Name="todoBackgroundCommandList">

<Example> pending tasks </Example>

<ListenFor> {command} task[s] </ListenFor>

<Feedback> Executing specific command </Feedback>

<VoiceCommandService Target="SimpleTodoVoiceCommandService"/>

</Command>

<PhraseTopic Label="command" Scenario="Search">

<Subject> pending </Subject>

</PhraseTopic>

</CommandSet>

</VoiceCommands>

<Command Name="todoBackgroundCommandList"><Example> pending tasks </Example><ListenFor> {command} task[s] </ListenFor><Feedback> showing {command} tasks </Feedback><VoiceCommandService

Target="SimpleTodoVoiceCommandService"/></Command>

Step 1

<?xml version="1.0" encoding="utf-8"?>

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

<CommandSet xml:lang="en-us" Name="MySimpleTodoCommandSet_en-us">

<CommandPrefix> My Simple To do </CommandPrefix>

<Example> pending tasks </Example>

<Command Name="todoBackgroundCommandList">

<Example> pending tasks </Example>

<ListenFor> {command} task[s] </ListenFor>

<Feedback> Executing specific command </Feedback>

<VoiceCommandService Target="SimpleTodoVoiceCommandService"/>

</Command>

<PhraseTopic Label="command" Scenario="Search">

<Subject> pending </Subject>

</PhraseTopic>

</CommandSet>

</VoiceCommands>

<Example> pending tasks </Example>

Step 1

<?xml version="1.0" encoding="utf-8"?>

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

<CommandSet xml:lang="en-us" Name="MySimpleTodoCommandSet_en-us">

<CommandPrefix> My Simple To do </CommandPrefix>

<Example> pending tasks </Example>

<Command Name="todoBackgroundCommandList">

<Example> pending tasks </Example>

<ListenFor> {command} task[s] </ListenFor>

<Feedback> Executing specific command </Feedback>

<VoiceCommandService Target="SimpleTodoVoiceCommandService"/>

</Command>

<PhraseTopic Label="command" Scenario="Search">

<Subject> pending </Subject>

</PhraseTopic>

</CommandSet>

</VoiceCommands>

<ListenFor> {command} task[s] </ListenFor>

Step 1

<?xml version="1.0" encoding="utf-8"?>

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

<CommandSet xml:lang="en-us" Name="MySimpleTodoCommandSet_en-us">

<CommandPrefix> My Simple To do </CommandPrefix>

<Example> pending tasks </Example>

<Command Name="todoBackgroundCommandList">

<Example> pending tasks </Example>

<ListenFor> {command} task[s] </ListenFor>

<Feedback> Executing specific command </Feedback>

<VoiceCommandService Target="SimpleTodoVoiceCommandService"/>

</Command>

<PhraseTopic Label="command" Scenario="Search">

<Subject> pending </Subject>

</PhraseTopic>

</CommandSet>

</VoiceCommands>

<Feedback> Executing specific command </Feedback>

Step 1

<?xml version="1.0" encoding="utf-8"?>

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

<CommandSet xml:lang="en-us" Name="MySimpleTodoCommandSet_en-us">

<CommandPrefix> My Simple To do </CommandPrefix>

<Example> pending tasks </Example>

<Command Name="todoBackgroundCommandList">

<Example> pending tasks </Example>

<ListenFor> {command} task[s] </ListenFor>

<Feedback> Executing specific command </Feedback>

<VoiceCommandService Target="SimpleTodoVoiceCommandService"/>

</Command>

<PhraseTopic Label="command" Scenario="Search">

<Subject> pending </Subject>

</PhraseTopic>

</CommandSet>

</VoiceCommands>

<VoiceCommandService Target="SimpleTodoVoiceCommandService"/>

Step 1

<?xml version="1.0" encoding="utf-8"?>

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

<CommandSet xml:lang="en-us" Name="MySimpleTodoCommandSet_en-us">

<CommandPrefix> My Simple To do </CommandPrefix>

<Example> pending tasks </Example>

<Command Name="todoBackgroundCommandList">

<Example> pending tasks </Example>

<ListenFor> {command} task[s] </ListenFor>

<Feedback> Executing specific command </Feedback>

<VoiceCommandService Target="SimpleTodoVoiceCommandService"/>

</Command>

<PhraseTopic Label="command" Scenario="Search">

<Subject> pending </Subject>

</PhraseTopic>

</CommandSet>

</VoiceCommands>

<PhraseTopic Label="command" Scenario="Search"><Subject> pending </Subject>

</PhraseTopic>

Step 1

Register VCD XML file on App Startup

private async Task RegisterVoiceCommands()

{

var storageFile =

await StorageFile.GetFileFromApplicationUriAsync(

new Uri("ms-appx:///MySimpleTodoCommands.xml"));

await

VoiceCommandDefinitionManager

.InstallCommandDefinitionsFromStorageFileAsync(storageFile);

}Step 2

Register VCD XML file on App Startup

Step 1

Handle Voice Command Activation

Step 3

Step 1

Step 2

Handle Voice Command Activationvar triggerDetails = taskInstance.TriggerDetails as AppServiceTriggerDetails;

if (triggerDetails?.Name == "SimpleTodoVoiceCommandService")

{

_deferral = taskInstance.GetDeferral();

var cancelledTokenSource = new CancellationTokenSource();

_voiceServiceConnection = VoiceCommandServiceConnection.FromAppServiceTriggerDetails(triggerDetails);

var voiceCommand = await _voiceServiceConnection.GetVoiceCommandAsync();

switch (voiceCommand.CommandName)

{

case "todoBackgroundCommandList":

var command = voiceCommand.Properties["command"][0];

if (command == "pending")

await ();

break;

default:

();

break;

}

}

top related