SpeechRecognitionEngine.RecognizeAsync Method (RecognizeMode)

Provides either single or multiple asynchronous recognition reoperations on recognition engine input.

Namespace: Microsoft.Speech.Recognition
Assembly: Microsoft.Speech (in microsoft.speech.dll)

Syntax

'Declaration




Parameters

  • mode
    A member of RecognizeMode enumeration specifying either multiple or single recognition operations.

Remarks

Depending the value of the mode argument, RecognizeAsync performs either on single asynchronous operation (mode is Single, and then completes, or performs multiple recognition operations (mode is Multiple).

If RecognizeAsynceech.Recognition.RecognizeMode) is called with mode set to Multiple, the recognition engine will continue working until terminaed with RecognizeAsyncCancel or RecognizeAsyncStop.

The results of each asynchronous recognition operations are obtained by event handlers, in particular RecognizeCompleted, SpeechRecognitionRejected, and SpeechRecognized.

If recognition has been successful, the Result property on the instance of RecognizeCompletedEventArgs passed to the RecognizeCompleted handler will not be null.

Recognition failure may be due either to time out, or by a failure of the recognition engine grammar. Time out values are set by BabbleTimeout and InitialSilenceTimeout of the current instance of SpeechRecognitionEngine.

Example

In the following example show the implementation of a start/stop button for a application with a graphical user interface using SpeechRecognitionEngine. Depending on the state of the application, when the button is clicked RecognizeAsync is called with either Single or Multiple.

private void _startRecogButton_Click(object sender, EventArgs eventArgs) {
    if (_startRecogButton.Text == "Start Speech Recognition") { //Toggle Speech Recogniztion on
        _startRecogButton.Text = "Stop Speech Recognition";
        if (_useMultiple) {
            _recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
        } else {
            _recognitionEngine.RecognizeAsync(RecognizeMode.Single);
        }
    } else {                                                      //Toggle Speech Recognition off
        _startRecogButton.Text = "Start Speech Recognition";
        if (_friendlyStop) {
            _recognitionEngine.RecognizeAsyncStop(); //Stop after current phrase is finished.
        } else {
            _recognitionEngine.RecognizeAsyncCancel(); //Stop before current phrase is finished.
        }

    }
}

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

SpeechRecognitionEngine Class
SpeechRecognitionEngine Members
Microsoft.Speech.Recognition Namespace