Windows Phone official example: Short Message dictation and Web Search grammars sample (speech recognition, text speech)

Source: Internet
Author: User

In Windows phone8, speech can be understood as voice control voice commands, speech recognition, and text speech text-to-speech (TTS ).

The example shows how to use the basic knowledge and speech recognition functions of predefined short messages and network search syntax.

Code download: http://code.msdn.microsoft.com/wpapps/Short-message-dictation-594c8a0a

Related Articles: http://www.cnblogs.com/sonic1abc/archive/2012/11/18/2775153.html

Speech recognition Speech Recognition sample code

Speechrecognizerui recowithui = new speechrecognizerui (); speechrecognitionuiresult recoresult; string luangestr = "ZH-CN"; // "fr-fr "; try {// query for a recognizer that recognizes French as spoken in France. ienumerable <speechrecognizerinformation> frenchrecognizers = from recognizerinfo in installedspeechrecognizers. all where recognizerinfo. language = luangestr select recognizerinfo; // set the recognizer to the top entry in the query result. recowithui. recognizer. setrecognizer (frenchrecognizers. elementat (0); // create a string array of China numbers. string [] nombres = {"1", "2", "3", "4", "5", "6", "7", "8 ", "9", "10"}; // string [] nombres = {"UN", "Deux", "trois", "quatre", "cinq ", "Six", "Sept", "huit", "Neuf", "Dix"}; // create a list grammar from the string array and add it to the grammar set. recowithui. recognizer. grammars. addgrammarfromlist ("chinanumbers", nombres); // recowithui. recognizer. grammars. addgrammarfromlist ("French", nombres); // display text to prompt the user's input. recowithui. settings. listentext = "say a China number"; // dire un nombre // give an example of ideal speech input. recowithui. settings. exampletext = "'1', '2', '3', '4'"; // load the grammar set and start recognition. recoresult = await recowithui. recognizewithuiasync (); If (recoresult. resultstatus = speechrecognitionuistatus. succeeded) {// output the speech recognition result. txtdictationresult. TEXT = "you said:" + recoresult. recognitionresult. text ;}} catch (exception ex) {MessageBox. show (ex. message );}

 

Text-to-speech (TTS) Sample Code

// Initialize a new instance of the speechsynthesizer. speechsynthesizer synth = new speechsynthesizer (); var voices1 = (from voice in installedvoices. all where voice. language = "ZH-CN" // & voice. gender = voicegender. male select voice); If (voices1! = NULL) synth. setvoice (voices1.elementat (1); await synth. speaktextasync ("2500 vehicles sold in the current period, exceeding the quota"); // "French (France)", "fr-fr" // read French
VaR voices = (from voice in installedvoices. all where voice. language = "fr-fr" // & voice. gender = voicegender. male select voice); // set the voice as identified by the query. if (voices! = NULL) synth. setvoice (voices. elementat (0); await synth. speaktextasync ("Bonjour, tu es libre ce soir? ");

 

 

Start Speech Recognition for Windows Phone 8

Http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206963 (V = vs.105). aspx

 

Handle errors in Windows Phone Voice applications

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

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.