2
votes

I've made an app that uses the SpeechRecognizer class to setup a simple grammar and recognize simple words.

When I run it on Win7 I notice two things.

1) The first time I start the app the Speech recognition bar (thingy) comes up, but the UI of my app is not shown (it is running as I can see in the Task Manager). When I start the app for the 2nd time (after killing the first instance) it display normally (with the windows speech recognition toolbar already running).

2) When I speak one of the words I'm recognizing in my app a 2nd time, it does not trigger an event -instead- it selects the text on my app where I print out in a listbox the history of the recognized words.

Note: When I remove the history listbox from the main screen, it works as expected. Apperently Win7 tries to find the word in my UI first and when it cannot find it - only then does it trigger my programmatic event...??

Both problems seem very weird to me.

More info on the app: Its a VS2008/.NET 3.0 WPF app written in C#. The application allows a user to edit setting groups (patches) for sending Midi commands. Each Patch is tagged with a phrase. When that Phrase is spoken (recognized by the app) all configured Midi commands are sent to the output(s). The history of patches that were recalled by the user are printed in a 'history' list on the apps main screen.

I hope someone can help me with this. Any suggestions are most welcome.

Thanx, Marc Jacobi

2

2 Answers

3
votes

I think you are using the shared speech recognizer (SpeechRecognizer). When you instantiate SpeechRecognizer you get a recognizer that can be shared by other applications and is typically used for building applications to control windows and applications running on the desktop.

It sounds like you want to use your own private recognition engine (SpeechRecognitionEngine). So instantiate a SpeechRecognitionEngine instead.

see http://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognizer(v=vs.90).aspx

What is the difference between System.Speech.Recognition and Microsoft.Speech.Recognition? and Disable built-in speech recognition commands? may also have some helpful info.

0
votes

I got it working, thanx!

The main difference between using the SpeechRecognizer and the SpeechRecognitionEngine are:

  • Construct the SpeechRecognitionEngine using a RecognizerInfo from InstalledRecognizers.
  • Call one of the SetInputToXxxx methods
  • Call RecognizeAsync(RecognizeMode.Multiple) to mimic the SpeechRecognizer (SpeechRecognized) events.
  • Call RecognizeCancel/Stop to quit.

Hope it helps.