,

Launching Your App via Voice Commands

So far in this chapter we have seen how speech recognition can be harnessed within an app, while the app is in execution. The speech capabilities of Windows Phone also allow your app to subscribe to speech recognition services even when your app is not running in the foreground—or not running at all—using a feature known as voice commands. Voice commands allow users to both launch your app and execute actions within your app.

Voice-command functionality can be added to your app by performing the following steps:

1. Create a Voice Command Definition (VCD) file. This is an XML document that declares all the spoken commands that users can say to initiate actions when launching your app.

2. Add code to register the VCD file with the phone’s voice-command system.

3. Add code to handle navigation and logic to execute commands.

In the sample for this section you see how to create a Weather Voice app that allows the user to request weather information for a particular location using voice commands. The app uses the Yahoo! Weather service to request the weather information for a specified location, which is then displayed on the phone.

The source code for this section is located in the Speech/VoiceCommands directory of the WPUnleashed.Examples project in the downloadable sample code.

We begin by looking at the placement and structure of VCD files. In the sample, the VoiceCommands.xml file defines the commands available to the entire WPUnleashed.Examples app.

To add a VCD file to your project, right-click the project node in the Solution Explorer and select Voice Command Definition from the Add New Item dialog. The VCD file is simply an XML file with its Build Action set to Content. There is no restriction on where the file can be located in your project.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.168.152