I have this code in your C # project: This code generates a dll that I use to use in another application Now, the evil bug: - When I run the startRecognition method in the beginning of the execution of other applications, this code works very well. But when I run it after some time, this code works but the handle method is never called. I think we have recognized the words as they appear on the Microsoft speech recognition application, but the handler method is never called. Do you know what is the problem with this code? Note: There are some codes in this project which are being executed at all. Can this be the problem? Because other code running, it does not allow you to run it?
public void startRecognition (string pName ) {PresentationName = pName; If (WaveNative.waveInGetNumDevs () & gt; 0) {string grammar = System.Environment.GetEnvironmentVariable ( "public") + "\\ SoundLog \\ submissions \\" + presentationName + "\\ SpeechRecognition \\ soundlog.cfg" ; If (Failkiksists (grammar)) (File.Delete (grammar);} ExecuteCommand (); with /// Create an instance of SpSharedRecoContextClass the incoming audio stream recContext = new SpSharedRecoContextClass () of /// interface will be used; // Create grammatical object recContext.CreateGrammar (1, out recGrammar); //recContext.CreateGrammar (2, Arjiarmamr 2); // set dictation mode //recGrammar2.SetDictationState (SpeechLib.SPRULESTATE.SPRS_ACTIVE) out; //recGrammar2.SetGrammarState(SPGRAMMARSTATE.SPGS_ENABLED); // set the appropriate grammatical mode (if the file. example (grammar)) {recGrammar.LoadCmdFromFil E (Grammar, SPLOADOPTIONS.SPLO_STATIC); //recGrammar.SetDictationState(SpeechLib.SPRULESTATE.SPRS_INACTIVE); recGrammar.SetGrammarState (SPGRAMMARSTATE.SPGS_ENABLED); Ragrammer STRUIstState (0, Spraylet. SPRS_Active);} /// For the validation program Take bind callback, which will be implemented /// when a set has been received sentences recognition. RecContext.Recognition + = new _IpeechRecoContextEvents_RecognitionEventHandler (validation handle); // System.Windows.Forms.MessageBox.Show (recContext.ToString ()); // Gramatica compilada}} private static void handleRecognition (integer StreamNumber, object StreamPosition, SpeechLib.SpeechRecognitionType RecognitionType, SpeechLib.ISpeechRecoResult result) {String temp = Result.PhraseInfo.GetText (0, -1, true); _recognizedText = ""; // System.Windows.Forms.MessageBox.Show (temp); // System.Windows.Forms.MessageBox.Show (Valid Word Number. ToString ()); Foreign words (word of the word in the recognized word) {if (temp.Contains (word)) {// System.Windows.Forms.MessageBox.Show ("yes"); _recognizedText = word; }}}
It may be that with the exception of startRecognition ()
in the second call before putting the handler can be added to the recContext.Recognition
. startRecognition ()
Everything Put try around / catch, and any exceptions that are thrown echo.
I will also produce the value of WaveNative.waveInGetNumDevs ()
in a log or trace file. If this is the & gt; No <0> to
the initialization ()
will not do anything.
Comments
Post a Comment