Windows Phone 官方樣本學習:Short message dictation and web search grammars sample(語音辨識,文字語音)

來源:互聯網
上載者:User

在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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.