SpeechRecognizer.AudioCaptureStateChanged event
Bing
The AudioCaptureStateChanged event is raised when the current speech recognition session moves from one state to another.
public event Windows.Foundation.TypedEventHandler<SpeechRecognizer,SpeechRecognitionAudioCaptureStateChangedEventArgs> AudioCaptureStateChanged
Use this event to signal UI changes in your speech controls to reflect the current state of the capture process.
The SpeechRecognitionAudioCaptureStateChangedEventArgs object associated with this event contains a SpeechRecognizerAudioCaptureState enumeration value that specifies the current state. For a list of valid states, see the SpeechRecognizerAudioCaptureState enumeration documentation.
Example
The following code example prints status information to a TextBlock named StatusBar.
var SR; function pageLoaded() { var credentials = new Bing.Speech.SpeechAuthorizationParameters(); credentials.clientId = "<YOUR CLIENT ID>"; credentials.clientSecret = "<YOUR CLIENT SECRET>"; SR = new Bing.Speech.SpeechRecognizer("en-US", credentials); SR.onaudiocapturestatechanged = SR_AudioCaptureStateChanged; } function SR_AudioCaptureStateChanged(sender, args) { var statusBar = document.getElementById("StatusBar"); switch (args.State) { case SpeechRecognizerAudioCaptureState.Canceled: statusBar.Text = "Operation cancelled."; break; case SpeechRecognizerAudioCaptureState.Cancelling: statusBar.Text = "Cancelling capture operation..."; break; case SpeechRecognizerAudioCaptureState.Complete: statusBar.Text = "Audio capture complete."; break; case SpeechRecognizerAudioCaptureState.Initializing: statusBar.Text = "Initializing audio capture..."; break; case SpeechRecognizerAudioCaptureState.Listening: statusBar.Text = "Listening..."; break; case SpeechRecognizerAudioCaptureState.Thinking: statusBar.Text = "Interpreting audio input..."; break; default: statusBar.Text = "Unknown capture state."; break; } }
Requirements
Minimum Supported Client | Windows 8 |
Required Extensions | Bing.Speech |
Namespace |
Show: