SpeechRecognitionEngine.InstalledRecognizers返回未安装的识别器

时间:2013-05-31 12:00:58

标签: 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();
    }
}

出于什么原因无法找到已安装的识别器?

编辑:

这是一个例外:{System.ArgumentException:找不到所需ID的识别器。 参数名称:culture    在System.Speech.Recognition.SpeechRecognitionEngine..ctor(CultureInfo文化)

和:var recognizers = SpeechRecognitionEngine.InstalledRecognizers();返回计数为0的集合

1 个答案:

答案 0 :(得分:3)

问题是我安装了Microsoft.Speech可以访问的语言包,当我切换到System.Speech时,我正在使用Microsoft.Speech