Jef*_*fnl 5 c# speech-recognition
我试图启动一个简单的语音识别程序,但是它不起作用,我已经安装了某些语言(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();
}
}
Run Code Online (Sandbox Code Playgroud)
由于什么原因无法找到已安装的识别器?
编辑:
例外是:{System.ArgumentException:找不到所需ID的识别器。参数名称:System.Speech.Recognition.SpeechRecognitionEngine..ctor的区域性(CultureInfo文化)
和:var recognizers = SpeechRecognitionEngine.InstalledRecognizers();返回计数为0的集合
问题是我安装了可以访问的语言包,当我切换到它时 Microsoft.Speech,我正在使用它。System.SpeechMicrosoft.Speech