Partager via


Note

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

AudioStateChangedEventArgs Class

Provides data for the AudioStateChanged event of the SpeechRecognitionEngine class.

Inheritance Hierarchy

System.Object
  System.EventArgs
    Microsoft.Speech.Recognition.AudioStateChangedEventArgs

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

Syntax

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

Remarks

An instance of AudioStateChangedEventArgs is created when the SpeechRecognitionEngine object raises the AudioStateChanged event. To obtain the new state of audio input, access the AudioState property in the handler for the event.

You can obtain the current state of the audio input to the SpeechRecognitionEngine at any time using the AudioState property.

Examples

The following example demonstrates an event handler for handling the changing audio state of a speech recognition engine.

private SpeechRecognitionEngine sre;

// Initialize the SpeechRecognitionEngine object. 
private void Initialize()
{
  sre = new SpeechRecognitionEngine();

  // Add a handler for the AudioStateChanged event.
  sre.AudioStateChanged += new EventHandler<AudioStateChangedEventArgs>(sre_AudioStateChanged);

  // Add other initialization code here.
}

// Handle the AudioStateChanged event. 
void sre_AudioStateChanged(object sender, AudioStateChangedEventArgs e)
{
  AudioState newState = e.AudioState;

  // Handle event here.
}

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

AudioStateChangedEventArgs Members

Microsoft.Speech.Recognition Namespace

AudioState

AudioStateChanged

AudioState