Exemplo n.º 1
0
        /// <summary>
        /// Execute initialization tasks.
        /// </summary>
        protected void Init()
        {
            ShowPenColor();

            // This requires that a Kinect is connected at the time of app startup.
            // To make the app robust against plug/unplug,
            // Microsoft recommends using KinectSensorChooser provided in Microsoft.Kinect.Toolkit (See components in Toolkit Browser).
            if (KinectV1Utils.StartKinectSensor() == null)
            {
                statusBarText.Text   = Properties.Resources.NoKinectReady;
                imgKinect.Visibility = Visibility.Hidden;
            }
            else
            {
                statusBarText.Text   = Properties.Resources.KinectReady;
                imgKinect.Visibility = Visibility.Visible;
            }

            speechSynthesis = new SpeechSynthesis();

            speechRecognition = new SpeechRecognitionKinectV1();                          //will fallback to same engine used by SpeechRecognition class automatically if it can't find Kinect V1 sensor

            speechRecognition.LoadGrammar(Properties.Resources.SpeechGrammar_en, "Main"); //could use SpeechGrammar_en.Create() to generate the grammar programmatically instead of loading it from an XML (resource) file
            speechRecognition.LoadGrammar(SpeechRecognitionUtils.CreateGrammarFromNames(ColorUtils.GetKnownColorNames(), "en", "Colors"));

            //setup recognition event handlers
            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(); //start speech recognition (set to keep on firing speech recognition events, not just once)
        }
Exemplo n.º 2
0
        /// <summary>
        /// Execute cleanup tasks.
        /// </summary>
        protected void Cleanup()
        {
            if (speechRecognition != null)
            {
                speechRecognition.Recognized    -= SpeechRecognition_Recognized;
                speechRecognition.NotRecognized -= SpeechRecognition_NotRecognized;
                speechRecognition.Stop(waitForCurrentRecognitionToComplete: false);

                IDisposable disposable = (speechRecognition as IDisposable);
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }

            speechSynthesis = null;
        }
Exemplo n.º 3
0
        public void LoadSpeechSynthesisPlugin()
        {
            Lazy <ISpeechSynthesis> plugin = PluginsCatalog.mefContainer.GetExports <ISpeechSynthesis>("SpeechLib.Synthesis").FirstOrDefault();

            speechSynthesis = (plugin != null) ? plugin.Value : null;
        }
 public void LoadSpeechSynthesisPlugin()
 {
     Lazy<ISpeechSynthesis> plugin = PluginsCatalog.mefContainer.GetExports<ISpeechSynthesis>("SpeechLib.Synthesis").FirstOrDefault();
      speechSynthesis = (plugin != null) ? plugin.Value : null;
 }