Пример #1
0
        public CommandRecognizer()
        {
            m_context = new SpSharedRecoContext();

            // We want to know when a phrase is recognized and also when one fails to be recognized
            m_context.EventInterests = SpeechRecoEvents.SRERecognition | SpeechRecoEvents.SREFalseRecognition;
            m_context.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(RecognitionHandler);
            m_context.FalseRecognition += new _ISpeechRecoContextEvents_FalseRecognitionEventHandler(FailedRecognitionHandler);

            m_grammar = m_context.CreateGrammar(0);
            m_grammar.Reset(0);
        }
Пример #2
0
        public NamesFromSpeech(Form1 parent, List <string> names)
        {
            // SAPI 5.4 Overview: http://msdn.microsoft.com/en-us/library/ee125077%28v=vs.85%29.aspx
            // Some code from https://github.com/kring/Voodoo-Voice/blob/master/VoiceRecognition/CommandRecognizer.cs

            m_parent = parent;
            m_names  = new List <string>();

            m_context = new SpSharedRecoContext();
            m_context.EventInterests = SpeechRecoEvents.SRERecognition;
            m_context.Recognition   += context_Recognition;

            m_grammar = m_context.CreateGrammar();
            m_grammar.Reset();

            foreach (string name in names)
            {
                AddRuleForName(name);
            }

            CommitAndActivate();
        }