Partager via


SpeechRecognizer.AudioLevelChanged event

 

The AudioLevelChanged event is raised when the user changes the audio level setting of the speech control. Use the SpeechRecognitionAudioLevelChangedEventArgs object associated with this event to get the current volume level.

Syntax

public event Windows.Foundation.TypedEventHandler<SpeechRecognizer,SpeechRecognitionAudioLevelChangedEventArgs> AudioLevelChanged

Example

The following event handler adjusts the opacity of a UI element named VolumeMeter in response to changes in speaking volume.

void SR_AudioLevelChanged(SpeechRecognizer sender,
    SpeechRecognitionAudioLevelChangedEventArgs args)
{
    var v = args.AudioLevel;
    if (v > 0) VolumeMeter.Opacity = v / 50;
    else VolumeMeter.Opacity = Math.Abs((v - 50) / 100);
}
function SR_AudioLevelChanged(args) {
    var volumeMeter = document.getElementById("VolumeMeter");
    var v = args.audioLevel;
    if (v > 0) volumeMeter.style.opacity = v / 50;
    else volumeMeter.style.opacity = Math.abs((v - 50) / 100);
}

Requirements

Minimum Supported Client

Windows 8

Required Extensions

Bing.Speech

Namespace

Bing.Speech