2011-05-18 256 views
5

如何通過按任意字母鍵獲取拼音聲音?例如,我想通過按'A'鍵來獲得A的語音音效。使用拼音聲音的文字轉語音

我正在使用Microsoft SAPI v5.1。你能指出我正確的方向嗎?

+0

你找到一個解決辦法? – 2011-05-25 18:52:23

+0

沒有........請幫助我我想要獲得語音學的聲音...不是一個正常的字母聲音 – user758475 2011-05-26 01:57:05

+0

不知道我明白當你打A鍵時,你期望什麼聲音?你是什​​麼意思拼音? – 2011-05-26 05:43:34

回答

4

添加對System.Speech組件的引用。

添加using System.Speech.Synthesis;

using (var speechSynthesizer = new SpeechSynthesizer()) 
{ 
    speechSynthesizer.Speak("A"); 
    speechSynthesizer.Speak("B"); 
    speechSynthesizer.Speak("C"); 
} 

例如像這樣:

using (var speechSynthesizer = new SpeechSynthesizer()) 
{ 
    while (true) 
    { 
     var consoleKey = Console.ReadKey(); 
     if (consoleKey.Key == ConsoleKey.Escape) 
      break; 
     var text = consoleKey.KeyChar.ToString(); 
     speechSynthesizer.Speak(text); 
    } 
}