0

I have problem with my speech recognition. It works on "English" windows with no problem. It also works on some "Foreign" windows too. But only some.

I'm getting that exception: The language for the grammar does not match the language of the speech recognizer

I added my own words to dictionary.

How can I fix it?

Hooch
  • 28,817
  • 29
  • 102
  • 161
  • Impressive exception. You're trying to make your Chinese user speak English then? – Hans Passant Apr 06 '12 at 16:51
  • @HansPassant Polish people can speak english but they are using Polish windows. This is example. – Hooch Apr 06 '12 at 17:30
  • Could you show some code (and grammar fragments)? Depending on how you're writing your grammar, this may be an expected error. – Eric Brown Sep 20 '13 at 16:15
  • possible duplicate of [How can i fix language for the grammar does not match the language of the speech recognizer error in vb](http://stackoverflow.com/questions/17012639/how-can-i-fix-language-for-the-grammar-does-not-match-the-language-of-the-speech) – elixenide Aug 15 '14 at 18:44
  • Possible duplicate of [The language for the grammar does not match the language of the speech recognizer](http://stackoverflow.com/questions/24630507/the-language-for-the-grammar-does-not-match-the-language-of-the-speech-recognize) – Nikolay Shmyrev Oct 16 '16 at 19:21

2 Answers2

-1

Not sure which version .net you are on, but I'll attempt to answer.

On your English Windows version, please navigate to C:\Program Files\Reference Assemblies\Microsoft\Framework[YOUR .NET VERSION]

You should find System.Speech.dll,

Make sure to bring this .dll over to your foreign computer, and everything should run smoothly.

voice
  • 1,326
  • 1
  • 11
  • 16
  • 1
    This won't work *at all*. System.Speech.dll is a wrapper around the SAPI client layer; the mismatch would be reported by the SR engine, which is independent of the SAPI client layer. – Eric Brown Sep 20 '13 at 16:13
-1

I had the same problem on my friends Computer. So I made this (it is just part of the code, because all the code is really long ):

...
RecognizerInfo recognizerInfo = null;

foreach (RecognizerInfo ri in SpeechRecognitionEngine.InstalledRecognizers())
{
   if ((ri.Culture.TwoLetterISOLanguageName.Equals("en")) && (recognizerInfo == null))
   {
      recognizerInfo = ri;
      break;
   }

}

SpeechRecognitionEngine SpeachRecognition = new SpeechRecognitionEngine(recognizerInfo);

GrammarBuilder gb = new GrammarBuilder(startLiserninFraze);
gb.Culture = recognizerInfo.Culture;
grammar = new Grammar(gb);
SpeachRecognition.RequestRecognizerUpdate();
SpeachRecognition.LoadGrammar(grammar);
SpeachRecognition.SpeechRecognized += SpeachRecognition_SpeechRecognized;
SpeachRecognition.SetInputToDefaultAudioDevice();
SpeachRecognition.RecognizeAsync(RecognizeMode.Multiple);
...

So this should work. My friends PC supported 2 instances of "en" or in "eng". Not sure why. So the code selects first one. I found some pieces of code on the internet and some of this is made by me.

 SpeachRecognition.SpeechRecognized += SpeachRecognition_SpeechRecognized;

is made to make an event when everything is recognized. just type:

SpeachRecognition.SpeechRecognized +=

and the press TAB button (atleast in VS 2013) few times. and then in the bottom of code it will generate something like this:

void SpeachRecognition_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
   {
       //then will be some line that you need to replace with your code
   }

I hope this will help. :)

Aphire
  • 1,621
  • 25
  • 55