Compartilhar via


Audio Input for Recognition

Your application can configure and monitor the audio input to a speech recognition engine using the members and types described below.

Configure the Audio Input

Applications can configure a SpeechRecognitionEngine instance running in-process to receive input using any of the SetInputToAudioStream(Stream, SpeechAudioFormatInfo), SetInputToDefaultAudioDevice(), SetInputToWaveFile(String), or SetInputToWaveStream(Stream) methods. In addition, you can set the input to null with the SetInputToNull() method, which is useful for emulating recognition or to cancel another input setting.

An application using the SpeechRecognizer class to control the shared recognizer in Windows uses the audio input setting specified in the Speech Properties dialog of the Windows Control Panel.

Monitor the Audio Input

To get information about the level, format, and state of audio being received for recognition, an application can register handlers for events or query the properties of the SpeechRecognizer and SpeechRecognitionEngine classes.

The AudioLevelUpdatedEventArgs class provides information about changes in the audio level when an AudioLevelUpdated event is raised. The AudioStateChangedEventArgs class provides information about changes in the state of the incoming audio when an AudioStateChanged event is raised, using a member of the AudioState enumeration.

In addition, the SpeechRecognizer and SpeechRecognitionEngine classes each have AudioLevel and AudioState properties that provide current information to the application. Detailed information about the format of the audio coming in to the speech recognition engine is available from the SpeechRecognizer.AudioFormat or SpeechRecognitionEngine.AudioFormat properties.

When an SpeechRecognizer.AudioSignalProblemOccurred or SpeechRecognitionEngine.AudioSignalProblemOccurred event is raised, applications can query the AudioSignalProblem property of the AudioSignalProblemOccurredEventArgs class to get a description of the problem.