Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The AudioCaptureStateChanged event is raised when the current speech recognition session moves from one state to another.
Syntax
public event Windows.Foundation.TypedEventHandler<SpeechRecognizer,SpeechRecognitionAudioCaptureStateChangedEventArgs> AudioCaptureStateChanged
Remarks
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;
}
}
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 |