public static void Main(string[] args)
        {
            // Obtain a KinectSensor if any are available
            KinectSensor sensor = (from sensorToCheck in KinectSensor.KinectSensors where sensorToCheck.Status == KinectStatus.Connected select sensorToCheck).FirstOrDefault();
            if (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");

                // Give a chance for user to see console output before it is dismissed
                Console.ReadKey(true);
                return;
            }

            sensor.Start();

            // Obtain the KinectAudioSource to do audio capture
            KinectAudioSource source = sensor.AudioSource;

            source.EchoCancellationMode = EchoCancellationMode.None; // No AEC for this sample
            source.AutomaticGainControlEnabled = false; // Important to turn this off for speech recognition
            System.Speech.Recognition.RecognizerInfo ri = System.Speech.Recognition.SpeechRecognitionEngine.InstalledRecognizers().FirstOrDefault();
            using (var recoEngine = new System.Speech.Recognition.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) => Console.Write(sargs.Result.Text);

                using (Stream s = source.Start())
                {

                    recoEngine.SetInputToAudioStream(s, new System.Speech.AudioFormat.SpeechAudioFormatInfo(System.Speech.AudioFormat.EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null));

                    Console.WriteLine("Dictating. Press ENTER to stop");

                    recoEngine.RecognizeAsync(System.Speech.Recognition.RecognizeMode.Multiple);

                    Console.ReadLine();
                    Console.WriteLine("Stopping recognizer ...");
                    recoEngine.RecognizeAsyncStop();

                }
            }

            sensor.Stop();
        }