public async Task TranscribeSpeechFromWavFileInput(SpeechConfig config)
 {
     using (var audioConfig = AudioConfig.FromWavFileInput(_wavFilePath))
     {
         using (var basicRecognizer = new SpeechRecognizer(config, audioConfig))
         {
             var speechToText = new SpeechToTextRecognizer(_streamWriter);
             await speechToText.RunRecognizer(basicRecognizer, RecognizerType.Base,
                                              _stopBaseRecognitionTaskCompletionSource).ConfigureAwait(false);
         }
     }
 }
        public async Task TranscribeSpeechFromAudioStream(SpeechConfig config, string person, int startSecond = 0, int endSecond = 0)
        {
            var audioFormat = AudioStreamFormat.GetWaveFormatPCM(SamplesPerSecond, BitsPerSample, Channels);

            using (var waveFileReader = new WaveFileReader(_wavFilePath))
            {
                var pullAudioInputStreamCallback = new VoiceAudioStream();
                TrimWavFile(waveFileReader, pullAudioInputStreamCallback, BytesPerSecond * startSecond,
                            BytesPerSecond * endSecond);
                var speechToText = new SpeechToTextRecognizer(person, _streamWriter);
                using (var audioConfig = AudioConfig.FromStreamInput(pullAudioInputStreamCallback, audioFormat))
                {
                    using (var basicRecognizer = new SpeechRecognizer(config, audioConfig))
                    {
                        await speechToText.RunRecognizer(basicRecognizer, RecognizerType.Base,
                                                         _stopBaseRecognitionTaskCompletionSource).ConfigureAwait(false);
                    }
                }
            };
        }