【发布时间】:2020-07-30 01:46:52
【问题描述】:
几天前,我想制作一个可以识别语音并将其转换为文本的应用程序。我需要很长时间才能运行 System.Speech.Recognition。我遇到了很多被质疑并总是以另一种方式回答的问题。没有一个对我有用。最后我得到了它的工作。
今天我启动了这个程序,它运行良好。它可以听到我的声音并认出我说的话。但大约 3 小时后它完全停止工作。我当时所做的只是拔下耳机并再次插入。我没有改变代码。我什至没有重新启动 Visual Studio。它仍然从以前开始运行。我现在也重新启动了计算机,但没有任何成功。我完全不知道发生了什么。我收到一条不会导致错误的消息(搜索此消息对我没有任何帮助):“信息:0:SAPI 未实现拼音字母选择。”
我知道这不是很多信息,如果您需要一些我没有提到的信息,请询问。谁能帮我解决这个问题?
代码如下:
using (recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("de-DE")))
{
// Create and load a dictation grammar.
Choices services = new Choices(new string[] { "rennen", "laufen", "schleichen", "renn", "lauf", "schleich", "jetzt", "kiste", "Generator", "Stop", "Halt", "Warte", "rechts", "links", "Rückwärts", "hinten" });
// Create a Grammar object from the GrammarBuilder and load it to the recognizer.
Grammar servicesGrammar = new Grammar(services);
recognizer.LoadGrammarAsync(servicesGrammar);
// Configure input to the speech recognizer.
recognizer.SetInputToDefaultAudioDevice();
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
recognizer.RecognizeAsync(RecognizeMode.Multiple);
// Keep the console window open.
while (true)
{
Thread.Sleep(5);
}
}
public void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
//Nothing Important here, because it never reaches that point
}
【问题讨论】:
-
如果它使用在线服务,则某些端口/IP 可能被关闭/禁止。
-
据我了解,它不使用在线服务。我正在使用内部语音识别。我还检查了控制面板-> 语音识别是否有效。确实如此。
标签: c# speech-recognition speech-to-text speech