use*_*475 5 .net c# sapi text-to-speech c#-4.0
如何通过按任何字母键来获得拼音?例如,我想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");
}
Run Code Online (Sandbox Code Playgroud)
例如这样:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
887 次 |
| 最近记录: |