EmulateRecognize Method (String, CompareOptions)

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Emulates audio input to the recognition engine, using text in place of audio for synchronous speech recognition, and specifies how the recognizer handles Unicode comparison between the phrase and the loaded speech recognition grammars

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

Syntax

Visual Basic (Declaration)
Public Function EmulateRecognize ( _
	inputText As String, _
	compareOptions As CompareOptions _
) As RecognitionResult
Visual Basic (Usage)
Dim instance As SpeechRecognitionEngine
Dim inputText As String
Dim compareOptions As CompareOptions
Dim returnValue As RecognitionResult

returnValue = instance.EmulateRecognize(inputText, _
	compareOptions)
C#
public RecognitionResult EmulateRecognize(
	string inputText,
	CompareOptions compareOptions
)

Parameters

inputText
Type: System..::..String

The text to use as the input phrase.

compareOptions
Type: System.Globalization..::..CompareOptions

A bitwise combination of the enumeration values that describe the type of comparison to use for the emulated recognition operation.

Return Value

Type: Microsoft.Speech.Recognition..::..RecognitionResult

The result for the recognition operation, or nullNothingnullptrunita null reference (Nothing in Visual Basic) if the operation is not successful.

Remarks

The speech recognizer raises the SpeechDetected, SpeechHypothesized, SpeechRecognitionRejected, and SpeechRecognized events as if the recognition operation is not emulated. The recognizer ignores new lines and extra white space and treats punctuation as literal input.

The only supported values of the compareOptions argument are the OrdinalIgnoreCase and IgnoreCase members of the CompareOptions enumerated type. All other members will generate a NotSupportedException exception or return a nullNothingnullptrunita null reference (Nothing in Visual Basic).

Examples

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.

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

// Emulate a button click in the emulateTextBox.
private void _emulateButton_Click(object sender, EventArgs e) 
{
  RecognitionResult result = _recognitionEngine.EmulateRecognize(_emulateTextBox.Text);
}

See Also