/// <summary>
        /// Creates a new speech recognition engine.
        /// </summary>
        /// <returns>A new speech recognition engine object.</returns>
        private SpeechRecognitionEngine CreateSpeechRecognitionEngine()
        {
            // Create the speech recognition engine
            var recognizer = MicrosoftSpeech.CreateSpeechRecognitionEngine(this.Configuration.Language, this.Configuration.Grammars);

            // Attach the event handlers for speech recognition events
            recognizer.SpeechDetected             += this.OnSpeechDetected;
            recognizer.SpeechHypothesized         += this.OnSpeechHypothesized;
            recognizer.SpeechRecognized           += this.OnSpeechRecognized;
            recognizer.SpeechRecognitionRejected  += this.OnSpeechRecognitionRejected;
            recognizer.AudioSignalProblemOccurred += this.OnAudioSignalProblemOccurred;
            recognizer.AudioStateChanged          += this.OnAudioStateChanged;
            recognizer.RecognizeCompleted         += this.OnRecognizeCompleted;
            recognizer.RecognizerUpdateReached    += this.OnRecognizerUpdateReached;
            recognizer.AudioLevelUpdated          += this.OnAudioLevelUpdated;
            recognizer.EmulateRecognizeCompleted  += this.OnEmulateRecognizeCompleted;
            recognizer.LoadGrammarCompleted       += this.OnLoadGrammarCompleted;

            // Create the format info from the configuration input format
            SpeechAudioFormatInfo formatInfo = new SpeechAudioFormatInfo(
                (EncodingFormat)this.Configuration.InputFormat.FormatTag,
                (int)this.Configuration.InputFormat.SamplesPerSec,
                this.Configuration.InputFormat.BitsPerSample,
                this.Configuration.InputFormat.Channels,
                (int)this.Configuration.InputFormat.AvgBytesPerSec,
                this.Configuration.InputFormat.BlockAlign,
                (this.Configuration.InputFormat is WaveFormatEx) ? ((WaveFormatEx)this.Configuration.InputFormat).ExtraInfo : null);

            // Specify the input stream and audio format
            recognizer.SetInputToAudioStream(this.inputAudioStream, formatInfo);

            return(recognizer);
        }
        /// <summary>
        /// Creates a new speech recognition engine.
        /// </summary>
        /// <returns>A new speech recognition engine object.</returns>
        private SpeechRecognitionEngine CreateSpeechRecognitionEngine()
        {
            // Create the speech recognition engine
            var recognizer = MicrosoftSpeech.CreateSpeechRecognitionEngine(this.Configuration.Language, this.Configuration.Grammars);

            // Attach the event handlers for speech recognition events
            recognizer.LoadGrammarCompleted += this.OnLoadGrammarCompleted;

            return(recognizer);
        }