/// <summary> /// Speech recognition from the microphone. The microphone is turned on and data from the microphone /// is sent to the Speech Recognition Service. A built in Silence Detector /// is applied to the microphone data before it is sent to the recognition service. /// </summary> void DoMicrophoneRecognition(MicrophoneRecognitionClient micClient) { int waitSeconds = (m_recoMode == SpeechRecognitionMode.LongDictation) ? 200 : 15; try { // Turn on the microphone and stream audio to the Speech Recognition Service micClient.StartMicAndRecognition(); Console.WriteLine("Start talking"); // sleep until the final result in OnResponseReceived event call, or waitSeconds, whichever is smaller. bool isReceivedResponse = micClient.WaitForFinalResponse(waitSeconds * 1000); if (!isReceivedResponse) { Console.WriteLine("{0}: Timed out waiting for conversation response after {1} ms", DateTime.UtcNow, waitSeconds * 1000); } } finally { // We are done sending audio. Final recognition results will arrive in OnResponseReceived event call. micClient.EndMicAndRecognition(); } }