SpeechRecognizerAudioCaptureState enumeration

 

The SpeechRecognizerAudioCaptureState enumeration specifies the current state of an audio capture operation.

Syntax

public enum SpeechRecognizerAudioCaptureState

The SpeechRecognizerAudioCaptureState Enumeration has the following members.

Members

Name

Description

Cancelling

The SpeechRecognizer is cancelling the audio capture operation.

Cancelled

The operation is cancelled.

Complete

The audio capture operation is complete.

Initializing

The SpeechRecognizer is initializing an audio capture session.

Listening

The SpeechRecognizer is listening to audio input.

Thinking

The SpeechRecognizer has finished listening and is now interpreting the input.

Unknown

The audio capture process has entered an unknown state.

Example

The following code example prints status information to a UI element 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

Bing.Speech