public void startSpeech()
        {
            System.Speech.Recognition.DictationGrammar dg = new System.Speech.Recognition.DictationGrammar();
            dg.Enabled = true;

            sre = new SpeechRecognitionEngine();
            sre.LoadGrammar(dg);

            sre.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
            sre.SetInputToDefaultAudioDevice();
        }
        private void startAudio()
        {
            var audioSource = this.sensor.AudioSource;
            audioSource.BeamAngleMode = BeamAngleMode.Adaptive;

            // This should be off by default, but just to be explicit, this MUST be set to false.
            audioSource.AutomaticGainControlEnabled = false;
            var kinectStream = audioSource.Start();

            this.preSpeechRecognizer.SetInputToAudioStream(
                kinectStream, new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
            // Keep recognizing speech until window closes
            this.preSpeechRecognizer.RecognizeAsync(RecognizeMode.Multiple);
            this.postSpeechRecognizer.SetInputToAudioStream(
                kinectStream, new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
            // Keep recognizing speech until window closes
            this.postSpeechRecognizer.RecognizeAsync(RecognizeMode.Multiple);

            sensor = (from sensorToCheck in KinectSensor.KinectSensors where sensorToCheck.Status == KinectStatus.Connected select sensorToCheck).FirstOrDefault();
            sensor.Start();

            source = sensor.AudioSource;
            source.EchoCancellationMode = EchoCancellationMode.None; // No AEC for this sample
            source.AutomaticGainControlEnabled = false; // Important to turn this off for speech recognition

            ri = System.Speech.Recognition.SpeechRecognitionEngine.InstalledRecognizers().FirstOrDefault();

            recoEngine = new System.Speech.Recognition.SpeechRecognitionEngine(ri.Id);

            customDictationGrammar = new System.Speech.Recognition.DictationGrammar();
            customDictationGrammar.Name = "Dictation";
            customDictationGrammar.Enabled = true;

            recoEngine.LoadGrammar(customDictationGrammar);

            recoEngine.SpeechRecognized += new EventHandler<System.Speech.Recognition.SpeechRecognizedEventArgs>(recoEngine_SpeechRecognized);

            s = source.Start();
            recoEngine.SetInputToAudioStream(s, new System.Speech.AudioFormat.SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
            recoEngine.RecognizeAsync(System.Speech.Recognition.RecognizeMode.Multiple);
        }
        private void testWindowLoaded(object sender, RoutedEventArgs e)
        {
            // Obtain a KinectSensor if any are available
            this.sensor = (from sensorToCheck in KinectSensor.KinectSensors where sensorToCheck.Status == KinectStatus.Connected select sensorToCheck).FirstOrDefault();
            if (this.sensor == null)
            {
                Console.WriteLine(
                        "No Kinect sensors are attached to this computer or none of the ones that are\n" +
                        "attached are \"Connected\".\n" +
                        "Attach the KinectSensor and restart this application.\n" +
                        "If that doesn't work run SkeletonViewer-WPF to better understand the Status of\n" +
                        "the Kinect sensors.\n\n" +
                        "Press any key to continue.\n");
                return;
            }

            this.sensor.Start();

            this.audioStream = this.sensor.AudioSource.Start();
            this.sensor.AudioSource.EchoCancellationMode = EchoCancellationMode.None; // No AEC for this sample
            this.sensor.AudioSource.AutomaticGainControlEnabled = false; // Important to turn this off for speech recognition

            RecognizerInfo ri = SpeechRecognitionEngine.InstalledRecognizers()[0];
            recoEngine = new SpeechRecognitionEngine(ri.Id);

            // Create the question dictation grammar.
            System.Speech.Recognition.DictationGrammar customDictationGrammar = new System.Speech.Recognition.DictationGrammar();
            customDictationGrammar.Name = "Dictation";
            customDictationGrammar.Enabled = true;

            // Create a SpeechRecognitionEngine object and add the grammars to it.
            recoEngine.LoadGrammar(customDictationGrammar);

            recoEngine.SpeechRecognized += (s, sargs) => SpeechRecognized(sargs);

            recoEngine.SetInputToAudioStream(audioStream, new System.Speech.AudioFormat.SpeechAudioFormatInfo(
                System.Speech.AudioFormat.EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));
            recoEngine.RecognizeAsync(RecognizeMode.Multiple);
        }