问题描述
我试图启动一个简单的语音识别程序,但是它不起作用,我已经安装了一些语言(en-GB和en-US),但是每当我使用以下语言时:
I am trying to get a simple speech recognition program started but it does not work, I've installed some languages (en-GB & en-US) but whenever I use the following:
它返回一个空集合。即使我只是尝试启动识别器,它也会返回 未安装识别器。但是当我重新安装一种语言时,它说它已经安装了。
it returns an empty collection. Even when I just try to start a recognizer it will return "no recognizer installed". But when I reinstall a language, it says that it is already installed.
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();
}
}
为什么找不到安装的识别器?
For what reason is it unable to find the installed recognizers?
编辑:
这是例外:{System.ArgumentException:找不到所需ID的识别器。
参数名称:System.Speech.Recognition.SpeechRecognitionEngine..ctor(CultureInfo文化)中的culture
This is the exception: {System.ArgumentException: No recognizer of the required ID found.Parameter name: culture at System.Speech.Recognition.SpeechRecognitionEngine..ctor(CultureInfo culture)
and: var识别器= SpeechRecognitionEngine.InstalledRecognizers();
返回一个计数为0的集合
and: var recognizers = SpeechRecognitionEngine.InstalledRecognizers();
returns a collection with a count of 0
推荐答案
The问题是我安装了 Microsoft.Speech
可以访问的语言包,而我在使用 System.Speech
我切换到 Microsoft.Speech
起作用了。
The problem was that I installed language packs that can be accessed by Microsoft.Speech
and I was using System.Speech
, when I switched to Microsoft.Speech
it worked.
这篇关于SpeechRecognitionEngine.InstalledRecognizers返回未安装识别器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!