Share via


SpeechRecognitionEngine.EmulateRecognize Method (String, CompareOptions)

Synchronously simulate audio input to the recognition engine with a String and specified case sensitivity.

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

Syntax

Parameters

  • inputText
    A String containing text 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.

Return Value

Returns an instance of RecognitionResult containing the results of speech recognition. The instance is null if recognition fails, or if the recognitionEngine is not enabled.

Remarks

Successful emulated recognition will generate the standard events also associated with audio recognition events such as SpeechRecognized.

The only supported values of the compareOptions argument are OrdinalIgnoreCase and

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 emulate speech recognition. The recognition emulation is performed ignoring case and performing an ordinal comparison.

private void EmulateTextBox_KeyPress(object sender, KeyPressEventArgs eventArgs) {
    if ((Keys)eventArgs.KeyChar == Keys.Enter) {
_recognitionEngine.EmulateRecognize(_emulateTextBox.Text, System.Globalization.CompareOptions.OrdinalIgnoreCase);

    }
}
// Emulate when Button is pressed in the emulateTextBox.
private void _emulateButton_Click(object sender, EventArgs e) {
    RecognitionResult result = _recognitionEngine.EmulateRecognize(_emulateTextBox.Text);
}

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