如何通过按任意字母键获取音标声音?例如,我想通过按下 'A' 键来获取 A
的音标声音。
我正在使用 Microsoft SAPI v5.1。你能指点我正确的方向吗?
如何通过按任意字母键获取音标声音?例如,我想通过按下 'A' 键来获取 A
的音标声音。
我正在使用 Microsoft SAPI v5.1。你能指点我正确的方向吗?
添加对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);
}
}