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.
private static SpeechRecognizer SR; void MainPage_Loaded(object sender, RoutedEventArgs e) { var credentials = new SpeechAuthorizationParameters(); credentials.ClientId = "<YOUR CLIENT ID>"; credentials.ClientSecret = "<YOUR CLIENT SECRET>"; SR = new SpeechRecognizer("en-US", credentials); SR.AudioCaptureStateChanged += SR_AudioCaptureStateChanged; } void SR_AudioCaptureStateChanged(SpeechRecognizer sender, SpeechRecognitionAudioCaptureStateChangedEventArgs args) { switch (args.State) { case SpeechRecognizerAudioCaptureState.Canceled: this.StatusBar.Text = "Operation cancelled."; break; case SpeechRecognizerAudioCaptureState.Cancelling: this.StatusBar.Text = "Cancelling capture operation..."; break; case SpeechRecognizerAudioCaptureState.Complete: this.StatusBar.Text = "Audio capture complete."; break; case SpeechRecognizerAudioCaptureState.Initializing: this.StatusBar.Text = "Initializing audio capture..."; break; case SpeechRecognizerAudioCaptureState.Listening: this.StatusBar.Text = "Listening..."; break; case SpeechRecognizerAudioCaptureState.Thinking: this.StatusBar.Text = "Interpreting audio input..."; break; default: this.StatusBar.Text = "Unknown capture state."; break; } }
Requirements
Minimum Supported Client | Windows 8 |
Required Extensions | Bing.Speech |
Namespace |
Show: