SpeechRecognitionEngine.EmulateRecognizeAsync Method (RecognizedWordUnit[], CompareOptions)

Asynchronously simulate audio input to the recognition engine with an array of RecognizedWordUnit objects and specified case sensitivity.

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

Syntax

'Declaration

Parameters

  • wordUnits
    Array of RecognizedWordUnit objects used as an input phrase in place of audio input during recognition emulation.
  • compareOptions
    A member of the CompareOptions enumeration determining whether the emulation is case sensitive or case insensitive.

Remarks

As EmulateRecognizeAsync methods return void, applications can only obtain results from asynchronous emulation of speech recognition by handling the events that would be produced by the raising of asynchronous emulation event EmulateRecognizeCompleted as well as actual audio input recognition events such as SpeechRecognized.

Note

The completion of asynchronous emulation event EmulateRecognizeCompleted is always generated after the audio input events such as SpeechRecognized.

A RecognizeCompleted event is not generated by the completion of a EmulateRecognizeAsync.

The only supported values of the compareOptions argument are OrdinalIgnoreCase and IgnoreCase

All other members of will generate a NotSupportedException exception or return a null. Emulated recognition ignores new lines and extra white space and treats punctuation literally, rather than letting it define phrases.

Example

In the following example, an application obtains text input through a Textbox, and uses it to asynchronously emulate speech recognition.

Information about the emulated recognition is returned to the user interface by the anonymous method used as the handler for EmulateRecognizeCompleted events.

private void _emulateButton_Click(object sender, EventArgs e) {
    _asyncEmulation = true;
    //RecognitionResult result = 
    _recognitionEngine.EmulateRecognizeAsync(_emulateTextBox.Text);
}

_recognitionEngine.EmulateRecognizeCompleted += delegate(object sender, EmulateRecognizeCompletedEventArgs eventArgs) {
    _asyncEmulation = false;
    Utils.DisplayAudioInputFormat(_audioStateLabel, _recognitionEngine);
    DisplayResult(eventArgs);
};

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
SpeechRecognize
SpeechRecognitionEngine.EmulateRecognize Method
SpeechRecognitionEngine.EmulateRecognizeAsync Method
RecognizedWordUnit Class
CompareOptions
EmulateRecognizeCompleted