コード例 #1
0
        public SpeechEngine(EventHandler<SpeechRecognizedUpdateArgs> recognizedEvent)
        {
            this.recognizedEvent = recognizedEvent;

            grammarManager = new GrammarManager();

            recognizer = new SpeechRecognitionEngine();
            recognizer.LoadGrammar(grammarManager.GetMenuGrammar());

            loadGrammarFromDB();

            recognizer.SetInputToDefaultAudioDevice();

            recognizer.SpeechRecognized += sr_SpeechRecognizedHandler;

            recognizer.RecognizeCompleted += sr_RecognizeCompletedHandler;
            recognizer.SpeechDetected += sr_SpeechDetectedHandler;
            recognizer.SpeechHypothesized += sr_SpeechHypothesizedHandler;
            recognizer.SpeechRecognitionRejected += sr_SpeechRecognitionRejectedHandler;
        }
コード例 #2
0
ファイル: SpeechEngine.cs プロジェクト: shayak/UTalkIPlay
        public SpeechEngine(EventHandler<SpeechRecognizedUpdateArgs> recognizedSongEvent, EventHandler<SpeechRecognizedUpdateArgs> recognizedMenuEvent)
        {
            var sw = new StreamWriter("seError.log");
            try
            {
                speaker = new SpeechSynthesizer();

                this.recognizedSongEvent = recognizedSongEvent;
                this.recognizedMenuEvent = recognizedMenuEvent;

                grammarManager = new GrammarManager();

                recognizer = new SpeechRecognitionEngine();

                recognizer.LoadGrammar(grammarManager.GetMenuGrammar());
                LoadGrammar();

                sw.WriteLine("loading mic...");

                recognizer.SetInputToDefaultAudioDevice();

                sw.WriteLine("loaded mic.");

                recognizer.SpeechRecognized += sr_SpeechRecognizedHandler;

                sw.WriteLine("subscribe to SR handler success");
            }
            catch (Exception ex)
            {
                sw.WriteLine("Exception Details: " + ex.Message + ex.StackTrace);
            }
            finally
            {
                sw.Close();
            }

            //recognizer.RecognizeCompleted += sr_RecognizeCompletedHandler;
            //recognizer.SpeechDetected += sr_SpeechDetectedHandler;
            //recognizer.SpeechHypothesized += sr_SpeechHypothesizedHandler;
            //recognizer.SpeechRecognitionRejected += sr_SpeechRecognitionRejectedHandler;
        }