5

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:

SpeechRecognitionEngine.InstalledRecognizers

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?

Edit:

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 recognizers = SpeechRecognitionEngine.InstalledRecognizers(); returns a collection with a count of 0

Nikolay Shmyrev
  • 24,897
  • 5
  • 43
  • 87
Jeffnl
  • 261
  • 1
  • 4
  • 21
  • Nowhere in your code do you call `SpeechRecognitionEngine.InstalledRecognizers`. Can you post the code you're actually using, and the full text of the exception that's thrown? – Dan Puzey May 31 '13 at 12:04
  • @ Dan Puzey, ive used the SpeechRecognitionEngine.InstalledRecognizers(); only for checking what was installed, i dont use it in the actual code – Jeffnl May 31 '13 at 12:09
  • So this would be the case regardless of the code that you've listed in the question? I can run that line alone in LinqPad and get a result - it seems that the code you've posted originally isn't relevant to the question. – Dan Puzey May 31 '13 at 12:11
  • 2
    Based on [this page](http://social.msdn.microsoft.com/Forums/en-US/kinectsdkaudioapi/thread/f59848eb-decb-4eae-9248-d103bdd81dca/) it seems that there may be some incompatbility between `Microsoft.Speech` and `System.Speech` namespaces. How are you installing your languages, and which namespace are you using? There's also a potential 32/64-bit incompatibility. – Dan Puzey May 31 '13 at 12:16
  • Yes it is relevant, quote: "Even when I just try to start a recognizer" the starting of the recognizer engine is what i posted there. – Jeffnl May 31 '13 at 12:16
  • ive donwloaded 'MSSpeech_SR_en-GB_TELE.msi' from the microsoft website, and i ame using System.Speech.Recognition; i ame running it on a x86 computer. – Jeffnl May 31 '13 at 12:18
  • 1
    Try going to Control Panel -> Ease of Access -> Speech Recognition -> Advanced Speech Options and ensure that the `Language` toolbar at the top has a recognizer set. If not, set one, click OK, and then try again. Also note that `Microsoft.Speech` language packs are not the same as `System.Speech` ones. – keyboardP May 31 '13 at 12:25
  • It finds more then one recognizer now, i ame now using microsoft.speech.recognition. but now when i try to load grammar, it says: The language for the grammar does not match the language of the speech recognizer. whay is this? i ame using the example on: http://msdn.microsoft.com/en-us/library/microsoft.speech.recognition.speechrecognitionengine(v=office.14).aspx – Jeffnl May 31 '13 at 12:47

1 Answers1

6

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.

Afzaal Ahmad Zeeshan
  • 15,669
  • 12
  • 55
  • 103
Jeffnl
  • 261
  • 1
  • 4
  • 21
  • 2
    @[Profile not found] Could you please share where you got the Microsoft.Speech language packs? I'm unable to find them. I have English (United States) language installed on my computer, but SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US")) still fails. – Zesty Aug 21 '17 at 09:05
  • 1
    For people who have the same problem as the person above: Downloading language packs for Microsoft Speech can be done here: https://www.microsoft.com/en-us/download/details.aspx?id=27224 – Cihan Kurt Apr 30 '20 at 02:52