在windows phone8中语音可以理解为三部分功能即: 语音控制 voice commands, 语音识别 speech recognition, 文字语音 text-to-speech (TTS)。
示例演示如何使用预定义的短消息和网络搜索语法的基础知识与语音识别功能。
代码下载:http://code.msdn.microsoft.com/wpapps/Short-message-dictation-594c8a0a
相关文章:http://www.cnblogs.com/sonic1abc/archive/2012/11/18/2775153.html
语音识别 speech recognition 示例代码
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 = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" }; //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 = "'一', '二', '三', '四' "; // 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) 示例代码
// 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辆汽车,已超额完成指标"); //"French (France)", "fr-FR" // 读法语
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?");
启动 Windows Phone 8 的语音识别
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206963(v=vs.105).aspx
处理 Windows Phone 语音应用中的错误
http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/jj662934(v=vs.105).aspx