×
Namespaces

Variants
Actions
Revision as of 14:26, 7 November 2012 by mehul_raje (Talk | contribs)

Voice Commands in Windows Phone 8

From Nokia Developer Wiki
Jump to: navigation, search

This article explains how to use voice commands in an application to perform actions, tasks or any initiative work.

Note.pngNote: This is a community entry in the Windows Phone 8 Wiki Competition 2012Q4.

WP Metro Icon Multimedia.png
SignpostIcon XAML 40.png
WP Metro Icon WP8.png
Article Metadata
Tested with
SDK: windows phone 8 sdk
Devices(s): windows phone 8 emulator
Compatibility
Platform(s): windows phone
Windows Phone 8
Article
Created: (08 Nov 2012)
Last edited: mehul_raje (07 Nov 2012)

Contents

Introduction

Windows phone 8 comes with very great speech functionality which includes 1. voice commands 2. speech recognition 3. text-to-speech, means now developer is able to add above mentioned functionality in his app. Using voice command functionality user is able to make his application responsible to respond voice commands.

With the help of phrase link to the specific application page application can perform specific task or any initiative work. You can simply check voice command functionality in your windows phone 7.5 and above by just holding start key.

'Refer following screen shots

Basic voice command listening UI Basic what can i say UI
Listening.png Whatcanisay.png


How to achieve

To add voice command functionality in application following steps needs to be followed

  1. Create voice command file
  2. Install voice command file in OS
  3. Write code to handle navigation handling and command execution.

Capabilities Require

ID_CAP_NETWORKING
ID_CAP_SPEECH_RECOGNITION
ID_CAP_MICROPHONE

Create Voice command definition file

How to create Voice command definition file

  1. Right click the windows phone project in visual studio
  2. Go to AddNew Item
  3. Select Voice Command Definition from list
  4. Give proper name to the VCD file.

Refer following screen shot

Add new VCD file in project
Addnewvcd.png

By default visual studio provides basic template of VCD file, now you need to update this VCD file with your own voice commands and there intended action. Typical voice command file contains

  1. Example phrase to show how user can invoke command
  2. The words or phrase that can be recognized to invoke command
  3. Action taken after the particular command is invoked with the help of page navigation.
  4. The text to display or speak to respond user after command recognized(note it uses TTS functionality to speak text)

Voice Command Definition file in detail

lets consider below example of VCD file

<?xml version="1.0" encoding="utf-8"?>
 
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.0">
<CommandSet xml:lang="en-US" Name="MyVoiceCommands">
<CommandPrefix>play</CommandPrefix>
<Example>play what is current date</Example>
 
<Command Name="Util">
<Example> What is current time </Example>
<ListenFor> what [is] current {options}</ListenFor>
<Feedback>showing current {options}</Feedback>
<Navigate Target="Target.xaml"/>
</Command>
 
<Command Name="Calculator">
<Example> 2 plus 3 </Example>
<ListenFor>{operand1} {operation} {operand2} </ListenFor>
<Feedback> Showing {operand1} {operation} {operand2}</Feedback>
<Navigate Target="Target.xaml"/>
</Command>
 
 
<PhraseList Label="options">
<Item>time</Item>
<Item>date</Item>
<Item>battery percentage</Item>
</PhraseList>
 
<PhraseList Label="operation">
<Item>plus</Item>
<Item>minus</Item>
</PhraseList>
 
<PhraseList Label="operand1">
<Item>1</Item>
<Item>2</Item>
</PhraseList>
 
<PhraseList Label="operand2">
<Item>1</Item>
<Item>2</Item>
</PhraseList>
 
</CommandSet>
</VoiceCommands>

VoiceCommands: This is root element of voice command definition file it can contains one or more CommandSet element each of which contains voice commands.

CommandSet: This element serves as container for all voice command, user can define actual voice commands under it for single language defined for xml:lang attribute of CommandSet, user can also specify Name for CommandSet optionally but it becomes useful for modifying CommandSet’s PhraseList at runtime.

CommandPrefix: This is child element of VoiceCommands which can be optional, but if present must be the first child element of CommandSet ,This element is used for giving name for application which user can speak in order to give voice command hence it is useful for the application which have long and difficult to pronounce names. In above example command prefix is “play”, means if user wants to give command to this application then he must use “play” word at the start of any command.

Command: This is compulsory child element for CommandSet Element This element defines action which needs to be taken after receiving voice command. Each command corresponds to specific page in your application, you can have multiple commands.

Example: This is compulsory child element of command, it can be used to help user for what he can say as in “What can I Say” screen, refer following screenshot. You can view this in supported command list of application, please refer following screen shot.

Supported commands for the application after successful installation of above VCD file
Diduknow.png


Summary

Remove Category:Draft when the page is complete or near complete


The "platform categories" will be displayed here in preview only - Copy paste relevant categories into text here

Version Hint

Windows Phone: [[Category:Windows Phone]]
[[Category:Windows Phone 7.5]]
[[Category:Windows Phone 8]]

Nokia Asha: [[Category:Nokia Asha]]
[[Category:Nokia Asha Platform 1.0]]

Series 40: [[Category:Series 40]]
[[Category:Series 40 1st Edition]] [[Category:Series 40 2nd Edition]]
[[Category:Series 40 3rd Edition (initial release)]] [[Category:Series 40 3rd Edition FP1]] [[Category:Series 40 3rd Edition FP2]]
[[Category:Series 40 5th Edition (initial release)]] [[Category:Series 40 5th Edition FP1]]
[[Category:Series 40 6th Edition (initial release)]] [[Category:Series 40 6th Edition FP1]] [[Category:Series 40 Developer Platform 1.0]] [[Category:Series 40 Developer Platform 1.1]] [[Category:Series 40 Developer Platform 2.0]]

Symbian: [[Category:Symbian]]
[[Category:S60 1st Edition]] [[Category:S60 2nd Edition (initial release)]] [[Category:S60 2nd Edition FP1]] [[Category:S60 2nd Edition FP2]] [[Category:S60 2nd Edition FP3]]
[[Category:S60 3rd Edition (initial release)]] [[Category:S60 3rd Edition FP1]] [[Category:S60 3rd Edition FP2]]
[[Category:S60 5th Edition]]
[[Category:Symbian^3]] [[Category:Symbian Anna]] [[Category:Nokia Belle]]

Add categories below using category selector.

377 page views in the last 30 days.
×