在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