Analysis of Windows Phone 8 voice command voice commands

Source: Internet
Author: User

The new Windows Phone 8 platform brings us a lot of surprises. the built-in support for Chinese voice commands is impressive.

We can encode it as WP8ProgramAdd the voice interaction function. For example, the scenario is as follows:

Take the Renren client as an example: You can press home on any page and then say "Renren status" to your mobile phone. In this case, if Weibo handles the problem internally, the status release page is displayed. This is a great user experience. So what should we do?

Next we will simulate this scenario (in fact, the Renren client does support voice commands :-))

Implementation

1. Configure the voice control file

Configure the following XML file: 

 <?  XML version = "1.0" encoding = "UTF-8" ?>     <  Voicecommands  Xmlns  = "Http://schemas.microsoft.com/voicecommands/1.0"  >  <  Commandset  XML: Lang  = "ZH-CN"  >  <  Commandprefix  > Renren </  Commandprefix >  <  Example  > Renren status </  Example  >     <  Command  Name  = "Navigate"  >  <  Example  > Renren status </ Example  >  <  Listenfor  > {Action} </  Listenfor  >  <  Feedback  > {Action }... </  Feedback  >  <  Navigate Target  = "/Views/editpage. XAML? Type = 2 & amp; from = voicecommand"  />  </  Command  >   <  Phraselist  Label  = "Action"  >  <  Item  > Sending status </  Item >  <  Item  > Status </  Item  >  </  Phraselist  >  </  Commandset  >  </  Voicecommands  >  

Let's take a look at the meanings of the nodes in the file:

First, XML: Lang. To identify Chinese commands, you must set the language to ZH-CN.

Commandprefix: the prefix of a command. A voice command consists of a prefix and a specific command.

Example: An example of a command, which is displayed on the following interface to indicate that a speech can be recognized

Command: a command tag represents an identified command.

Listenfor: The {action} action is used in the phraselist to define the action.

The command is one of the following

Feedback

Navigate target, it is the target address in the program to be navigated after the command is identified (note that because our configuration file is of the XML type, escape & when there are many navigation parameters)

Paraselist: the command to be recognized. You can add any text you want to recognize, such as <item> take you away </item>.

The simple explanation of this file is here. For the structure of this configuration file, we only need to process the voicecommand and second in the client.TileMake sure they are consistent.

2. Add this file to the project (needless to say)

3. Add the initialization command in the clientCode

AwaitVoicecommandservice. installcommandsetsfromfileasync (NewUri ("MS-appx: // voice. xml", Urikind. Absolute ));

Note that the absolute path in the preceding format must be used. Otherwise, an error is reported because of the URI type. (If you are interested, refer to the document first)

The msdn documentation for this is attached:

Http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/jj206959 (V = vs.105). aspx

In this way, we can easily add voice control to our program. This article does not cover higher business requirements. It just gives you a simple understanding of Windows Phone 8 voice control.

If you have any questions, please leave a message or join the QQ group: 182659848

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.