/// <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)
        }
Beispiel #2
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     base.OnNavigatedFrom(e);
     Utils.RunOnSeparateThread(() =>
     {
         SpeechRecognitionUtils.Stop();
         SpeechRecognitionUtils.commandBox = null;
     });
 }
Beispiel #3
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     base.OnNavigatedFrom(e);
     SpeechRecognitionUtils.Stop();
     SpeechRecognitionUtils.commandBox = null;
 }