Example #1
0
        private void StartSpeechRecognition()
        {
            if (speechRecognition == null)
            {
                return;
            }

            try
            {
                string grammarsFolder = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Grammars", "SRGS");
                speechRecognition.LoadGrammar(new FileStream(Path.Combine(grammarsFolder, "TrackingCam_en.xml"), FileMode.Open), "TrackingCam");

                speechRecognition.Recognized    += SpeechRecognition_Recognized;
                speechRecognition.NotRecognized += SpeechRecognition_NotRecognized;

                /*
                 * //For long recognition sessions (a few hours or more), it may be beneficial to turn off adaptation of the acoustic model.
                 * //This will prevent recognition accuracy from degrading over time.
                 * speechRecognition.AcousticModelAdaptation = false;
                 */

                speechRecognition.Start();
            }
            catch (Exception e)
            {
                speechRecognitionKinect = null;
                speechRecognition       = null;
                MessageBox.Show(e.Message);
            }
        }
Example #2
0
        public void LoadSpeechRecognitionPlugin()
        {
            Lazy <ISpeechRecognitionKinect> plugin1 = PluginsCatalog.mefContainer.GetExports <ISpeechRecognitionKinect>("SpeechLib.Recognition.KinectV1").FirstOrDefault();

            speechRecognition = speechRecognitionKinect = (plugin1 != null) ? plugin1.Value : null;

            if (speechRecognition == null) //SpeechRecognitionKinect plugin couldn't be loaded, try to fallback to the SpeechRecognition one (which uses the default audio source as input)
            {
                Lazy <ISpeechRecognition> plugin2 = PluginsCatalog.mefContainer.GetExports <ISpeechRecognition>("SpeechLib.Recognition").FirstOrDefault();
                speechRecognition = (plugin2 != null) ? plugin2.Value : null;
            }

            if (speechRecognition != null)
            {
                StartSpeechRecognition();
            }
        }