0
votes

I need to detect the user voice when they pick-up the reciever on the other end.

Because Modems usually start playing files (playback terminal) when the first ring goes there. So I planned to use speech recognition when they say "hello", it can start playing the file until wait for playing file.

Or even any noise interference it can start speak.

I accomplished this with few settings. I found few common words that my engine detects when we speak and the words that comes when it's ringing. It works fine as a stand alone application but if I try to integrate this with my application it just does not raises "SpeechHypothesized" event.

I cant understand why this happens.

If i see using a break point, the engine is having the delegate assign and invocation property also is initialized properly but than to is doesn't call the event. For calling I'm using C4F tapi manager and for speech recognition i'm using System.Speech library of .Net 3.5.

The code for events is as follows :

 engine.SpeechDetected += new EventHandler<SpeechDetectedEventArgs>(engine_SpeechDetected);
 engine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(engine_SpeechRecognized);
 engine.SpeechHypothesized+=new EventHandler<SpeechHypothesizedEventArgs> (engine_SpeechHypothesized);                   
 engine.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(engine_SpeechRecognitionRejected);

All event's are raised except the speechhypothesized event.

Any idea why this happens ????

EDIT:

Error is not thrown by the service it's Windows Form that throws the error!!!

The Code is as follows for speech recognition :

System.Collections.ObjectModel.ReadOnlyCollection<RecognizerInfo>

recognizedSpeeches = System.Speech.Recognition.SpeechRecognitionEngine.InstalledRecognizers(); if (recognizedSpeeches != null) {
Console.WriteLine("Recognized Speeches:");
int recognizerNumber = 0;

                    engine = new SpeechRecognitionEngine(recognizedSpeeches[recognizerNumber]);

                    engine.SetInputToDefaultAudioDevice();
                    engine.SpeechDetected -= new

EventHandler(engine_SpeechDetected); engine.SpeechRecognized -= new EventHandler(engine_SpeechRecognized); engine.SpeechHypothesized -= new EventHandler(engine_SpeechHypothesized); engine.SpeechRecognitionRejected -= new EventHandler(engine_SpeechRecognitionRejected); engine.SpeechDetected += new EventHandler(engine_SpeechDetected); engine.SpeechRecognized += new EventHandler(engine_SpeechRecognized); engine.SpeechHypothesized+=new EventHandler(engine_SpeechHypothesized); engine.SpeechRecognitionRejected += new EventHandler(engine_SpeechRecognitionRejected); engine.LoadGrammar(new DictationGrammar());
RecognitionResult srResult = engine.Recognize(new TimeSpan(0, 0, 30)); }

Any clue????

1

1 Answers

0
votes

I solved my problem to an extent by calling the Console application from my form. It's working if I start a Console application from my windows Form and it's not working with Windows Service. I don't know why Windows service is not responding or it's not working. It might be also because Windows Service by default don't work with desktop and Hypothesized event might raised only with that or I really don't or can't understand this strange behavior. And one more strange behavior of System.Speech I found is that it will not allow to set SpeechRecognitionEngine's to "InputToDefaultAudioDevice". Whenever I try to use the function "engine.SetInputToDefaultAudioDevice() " it just throws error(only from Window's Form). I don't know why??? Hmmmm System.Speech class works differently with different C# applications and it's best with console. I don't know whether this statistics is rite or not but according the observation it sounds in that way.

Right now I solved the problem by starting the Console application from my form to recognize and it's working fine also.