I am writing a little application that is supposed to listen for user commands and send keystrokes to another program. I am using Speech Recognition Engine Class but my script doesn’t work properly.
If I use a custom grammar (with very few words like “start” or “exit”) the program will always recognize one of the my words even though I said something completely different.
For istance I say “stackoverflow” and the program recognizes “start”.
With a default dictionary the program becomes almost impossible to use (I have to be 100% correct otherwise it won’t understand).
The strange thing is that if I use Speech Recognizer instead of Speech Recognition Engine my program works perfect but ofcourse everytime I say something unrelated it messes up because Windows Speech Recognition handles the result and I don’t want that to happen. That is the reason why I am using Speech Recognition Engine actually.
What am I doing wrong?
Choices c = new Choices(new string[] { "use", "menu", "map", "save", "talk", "esc" });
GrammarBuilder gb = new GrammarBuilder(c);
Grammar g = new Grammar(gb);
sr = new SpeechRecognitionEngine();
sr.LoadGrammar(g);
sr.SetInputToDefaultAudioDevice();
sr.SpeechRecognized += sr_SpeechRecognized;
Almost forgot, I don’t know if that’s relevant but I am using Visual Studio 11 Ultimate Beta.
For each speech recognition result detected you also receive the confidence for the recognition – a low confidence level would indicate that the engine is “not so sure” about the result and you might want to reject it, e.g.: