我正在尝试启动一个简单的语音识别程序,但它不起作用,我已经安装了一些语言(en-GB 和 en-US),但每当我使用以下内容时:
SpeechRecognitionEngine.InstalledRecognizers
它返回一个空集合。即使我只是尝试启动识别器,它也会返回“未安装识别器”。但是当我重新安装一种语言时,它说它已经安装了。
using ( SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US")))
{
// Create and load a dictation grammar.
recognizer.LoadGrammar(new DictationGrammar());
// Add a handler for the speech recognized event.
recognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
// Configure input to the speech recognizer.
recognizer.SetInputToDefaultAudioDevice();
// Start asynchronous, continuous speech recognition.
recognizer.RecognizeAsync(RecognizeMode.Multiple);
// Keep the console window open.
while (true)
{
Console.ReadLine();
}
}
由于什么原因无法找到已安装的识别器?
编辑:
这是一个例外:{System.ArgumentException:找不到所需 ID 的识别器。参数名称:System.Speech.Recognition.SpeechRecognitionEngine..ctor 处的文化(CultureInfo 文化)
and:var recognizers = SpeechRecognitionEngine.InstalledRecognizers();
返回一个计数为 0 的集合