RecognizeAsyncStop Method

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Stops asynchronous recognition after the current recognition operation completes.

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

Syntax

Visual Basic (Declaration)
Public Sub RecognizeAsyncStop
Visual Basic (Usage)
Dim instance As SpeechRecognitionEngine

instance.RecognizeAsyncStop()
C#
public void RecognizeAsyncStop()

Remarks

This method finalizes asynchronous recognition without truncating input. If the current asynchronous recognition operation is receiving input, the recognizer continues accepting input until the current recognition operation is completed. The recognizer raises the RecognizeCompleted or EmulateRecognizeCompleted event when an asynchronous operation is stopped, and sets the Cancelled property of the RecognizeCompletedEventArgs to true. This method stops asynchronous operations initiated by the RecognizeAsync and EmulateRecognizeAsync methods.

To stop asynchronous recognition without truncating the input, use the RecognizeAsyncCancel()()()() method.

Examples

The following example shows a graphical user interface which uses a button to start and stop a SpeechRecognitionEngine. When the user clicks the start/stop button while the SpeechRecognitionEngineis running, either RecognizeAsyncCancel or RecognizeAsyncStop is called depending on the state of the application.

 Copy imageCopy Code
private void _startRecogButton_Click(object sender, EventArgs eventArgs) {
    if (_startRecogButton.Text == "Start Speech Recognition") { //Toggle Speech Recognition 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.
        }

    }
}

See Also