Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

SpeechRecognitionEngine.RecognizeAsyncStop Method

Stops asynchronous recognition after the current recognition operation completes.

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

Syntax

'Declaration
Public Sub RecognizeAsyncStop
'Usage
Dim instance As SpeechRecognitionEngine

instance.RecognizeAsyncStop()
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.

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

Reference

SpeechRecognitionEngine Class

SpeechRecognitionEngine Members

Microsoft.Speech.Recognition Namespace