Friday, 6 June 2014

Voice commands

• Set up your project capabilities:
– D_CAP_SPEECH_RECOGNITION,
– ID_CAP_MICROPHONE,
– ID_CAP_NETWORKING

• Create a new Voice Command Definition

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

<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.0">
  <CommandSet xml:lang="en-US">
    <CommandPrefix>Contoso Widgets</CommandPrefix>
    <Example> Show today's specials </Example>

    <Command Name="showWidgets">
      <Example> Show today's specials </Example>
      <ListenFor> [Show] {widgetViews} </ListenFor>
      <ListenFor> {*} [Show] {widgetViews} </ListenFor>
      <Feedback> Showing {widgetViews} </Feedback>
      <Navigate Target="/favorites.xaml"/>
    </Command>    

    <PhraseList Label="widgetViews">
      <Item> today's specials </Item>
      <Item> best sellers </Item>      
    </PhraseList>
  </CommandSet>
</VoiceCommands>

Install the Voice Command Definition (VCD) file

await VoiceCommandService.InstallCommandSetsFromFileAsync( new Uri("ms-appx:///ContosoWidgets.xml") );

VCD files need to be installed again when a 
backup is restored on a device.

Voice commands parameters are included in the QueryString property of the NavigationContext

"/favorites.xaml voiceCommandName=showWidgets&widgetViews=best%20sellers&reco=Contoso%20Widgets%Show%20best%20sellers"

Asterisks in ListenFor phrases are passed as “…”

– In other words, it is not possible to receive the actual text that matched the asterisk.

No comments:

Post a Comment

Wikipedia

Search results