Bagikan melalui


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

SpeechRecognitionEngine.AudioLevelUpdated Event

Raised when the SpeechRecognitionEngine reports the level of its audio input.

Namespace:  Microsoft.Speech.Recognition
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

'Declaration
Public Event AudioLevelUpdated As EventHandler(Of AudioLevelUpdatedEventArgs)
'Usage
Dim instance As SpeechRecognitionEngine
Dim handler As EventHandler(Of AudioLevelUpdatedEventArgs)

AddHandler instance.AudioLevelUpdated, handler
public event EventHandler<AudioLevelUpdatedEventArgs> AudioLevelUpdated

Remarks

The SpeechRecognitionEngine raises this event multiple times per second. The frequency with which the event is raised depends on the computer on which the application is running.

To get the audio level at the time of the event, use the AudioLevel property of the associated AudioLevelUpdatedEventArgs. To get the current audio level of the input to the recognizer, use the recognizer's AudioLevel property.

When you create an AudioLevelUpdated delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see Events and Delegates.

Examples

The following example adds a handler for the AudioLevelUpdated event to a SpeechRecognitionEngine object. The handler outputs the new audio level to the console.

private SpeechRecognitionEngine recognizer;

// Initialize the SpeechRecognitionEngine object. 
private void Initialize()
{
  recognizer = new SpeechRecognitionEngine();
 
  // Add an event handler for the AudioLevelUpdated event.
  recognizer.AudioLevelUpdated += 
   new EventHandler<AudioLevelUpdatedEventArgs>(recognizer_AudioLevelUpdated);

  // Add other initialization code here.

}

// Write the audio level to the console when the AudioLevelUpdated event is raised.
void recognizer_AudioLevelUpdated(object sender, AudioLevelUpdatedEventArgs e)
{
  Console.WriteLine("The audio level is now: {0}.", e.AudioLevel);
}

See Also

Reference

SpeechRecognitionEngine Class

SpeechRecognitionEngine Members

Microsoft.Speech.Recognition Namespace

AudioLevelUpdatedEventArgs

AudioLevel