Share via


Note

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

AudioLevelUpdatedEventArgs Class

Provides data for the AudioLevelUpdated event.

Inheritance Hierarchy

System.Object
  System.EventArgs
    Microsoft.Speech.Recognition.AudioLevelUpdatedEventArgs

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

Syntax

'Declaration
Public Class AudioLevelUpdatedEventArgs _
    Inherits EventArgs
'Usage
Dim instance As AudioLevelUpdatedEventArgs
public class AudioLevelUpdatedEventArgs : EventArgs

Remarks

An instance of AudioLevelUpdatedEventArgs is created when the SpeechRecognitionEngine object raises the SpeechRecognitionEngine.AudioLevelUpdated event. To obtain the new level of audio input, access the AudioLevel property in the handler for the event.

You can obtain the current level of the input to the SpeechRecognitionEngine at any time using the AudioLevel property.

Examples

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

AudioLevelUpdatedEventArgs derives from EventArgs.

private SpeechRecognitionEngine sre;

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

  // Add other initialization code here.
}

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

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

AudioLevelUpdatedEventArgs Members

Microsoft.Speech.Recognition Namespace