views:

574

answers:

3

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.

  1. Open Control Panel, search for "speech", then click on "Start speech recognition".
  2. Open Visual C#, create a new Windows Forms project
  3. Copy and paste the code from the first answer on this Stack Overflow question into the project.
  4. Add the necessary reference to System.Speech.
  5. Run the program, with the speech recognition applet still running.
  6. Say "Start listening".
  7. 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?

+2  A: 

I think you haven't linked the Form1 load event to the Form1_Load routine in the designer. I followed your steps exactly, and had the same results; see if you can get a breakpoint anywhere in Form1_Load.

Once I edited the designer to make sure that Form1_Load actually got called, it ran fine.

Eric Brown
Yes, I did link the event. Of course I tried setting a breakpoint; the code in Form1_Load does run. You say "it ran fine" - did you try the speech recognition and did it actually recognise the numbers for you?
Timwi
Yep; I said 'sixty-five', and '65' showed up.
Eric Brown
A: 

From the lack of answers I suspect it works for everyone else but not for me. Thus, looks like the answer is "it's not possible".

Timwi
A: 

If you read other posts in the same thread, there is one which says you should add the numbers as one, two, etc. rather than 1, 2...

erikkallen