Speech Recognition in Windows 7 _Urgent

Jul 7 2010 3:27 AM
Hi All,

I'm developing a speech recognition application using MS VS2008 C# language. I have developed it correctly and it captures only the words i filter using below code. So only when the application is run, my voice is detected by the OS. Once I close the application i can't handle any of the windows control. So this what i need and it is done in Windows XP with SDK 5.1.

But now i'm using Windows 7 and this speech recognition is an inbuilt part in there. So i dont want to install any packages like SDK... But the problem that i'm having over there is, when i run the application it is not only responds the application commands but it responds whatever i say and mess up everything. For an example, sometimes it closes the application,prompt help menus likewise......So i want to disable this feature and i just want OS to responds only my commands which are defined in the application @ run time. I tried disable this inbuilt application once, but then my application didn't respond at all. So i think it should be there and i need to say OS to respond only commands available in the application.

I think now you clear about my problem. I think the people who use windows 7 face this issue.
If anybody can please give me a help. It will be a big help for me.

// Sample code for your reference


class voiceRecognition
    {

        SpSharedRecoContext objRecoContext = null;
        ISpeechRecoGrammar grammar = null;
        ISpeechGrammarRule menuRule = null;
        public string text1 = "";
        public string text2 = "";

        public voiceRecognition()
        {
            //Commands
            try
            {
                objRecoContext = new SpeechLib.SpSharedRecoContext();
                // Assign a eventhandler for the Hypothesis Event.
                objRecoContext.Hypothesis += new _ISpeechRecoContextEvents_HypothesisEventHandler(Hypo_Event);
                // Assign a eventhandler for the Recognition Event.
                objRecoContext.Recognition += new
                    _ISpeechRecoContextEvents_RecognitionEventHandler(Reco_Event);
                //Creating an instance of the grammer object.
                grammar = objRecoContext.CreateGrammar(0);

                //Activate the Menu Commands.           
                menuRule = grammar.Rules.Add("MenuCommands", SpeechRuleAttributes.SRATopLevel | SpeechRuleAttributes.SRADynamic, 1);
                object PropValue = "";
                menuRule.InitialState.AddWordTransition(null, "Go", " ", SpeechGrammarWordType.SGLexical, "Go", 1, ref PropValue, 1.0F);
                menuRule.InitialState.AddWordTransition(null, "Brake", " ", SpeechGrammarWordType.SGLexical, "Brake", 2, ref PropValue, 1.0F);
                menuRule.InitialState.AddWordTransition(null, "Reverse", " ", SpeechGrammarWordType.SGLexical, "Reverse", 3, ref PropValue, 1.0F);
                menuRule.InitialState.AddWordTransition(null, "Hand", " ", SpeechGrammarWordType.SGLexical, "Hand", 4, ref PropValue, 1.0F);
                menuRule.InitialState.AddWordTransition(null, "Exit", " ", SpeechGrammarWordType.SGLexical, "Exit", 5, ref PropValue, 1.0F);
                menuRule.InitialState.AddWordTransition(null, "Menu", " ", SpeechGrammarWordType.SGLexical, "Menu", 6, ref PropValue, 1.0F);
                menuRule.InitialState.AddWordTransition(null, "Left", " ", SpeechGrammarWordType.SGLexical, "Left", 7, ref PropValue, 1.0F);
                menuRule.InitialState.AddWordTransition(null, "Right", " ", SpeechGrammarWordType.SGLexical, "Right", 8, ref PropValue, 1.0F);
                menuRule.InitialState.AddWordTransition(null, "Straight", " ", SpeechGrammarWordType.SGLexical, "Straight", 9, ref PropValue, 1.0F);
                grammar.Rules.Commit();
                grammar.CmdSetRuleState("MenuCommands", SpeechRuleState.SGDSActive);
            }
            catch (Exception ex)
            { }
        }


        private void Reco_Event(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
        {
            text1 = Result.PhraseInfo.GetText(0, -1, true);
        }

        private void Hypo_Event(int StreamNumber, object StreamPosition, ISpeechRecoResult Result)
        {
            text2 = Result.PhraseInfo.GetText(0, -1, true);
  
        }

        
    }



Thank you,
Charith

Answers (1)