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