I am trying to write a program that supports speech recognition via a custom (specialised) grammar. However, the SpeechRecognized event never fires, and the speech recognition applet acts as if the grammar didn't exist.
Here are my precise steps. Please tell me where I am going wrong.
- Open Control Panel, search for "speech", then click on "Start speech recognition".
- Open Visual C#, create a new Windows Forms project
- Copy and paste the code from the first answer on this Stack Overflow question into the project.
- Add the necessary reference to System.Speech.
- Run the program, with the speech recognition applet still running.
- Say "Start listening".
- Say a number between 1 and 100.
The label's text never changes from its default value ("label1"), so it seems that rec_SpeechRecognized() is never called, i.e. the SpeechRecognized event never fires. If I say a number that sounds somewhat similar to the name of an open window or a program in my start menu, it'll ask me if that is what I meant. It appears to be completely agnostic of the custom grammar I just defined.
I tried lots of examples I found on the web, which are all pretty much equivalent to the example in that answer I linked to, only with different grammar. I get the same result for all of them, so I assume I must be doing something else wrong.
What am I doing wrong?