EmulateRecognizeAsync Method (String, CompareOptions)

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Emulates input of a phrase to the speech recognizer, using text in place of audio for asynchronous 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 Sub EmulateRecognizeAsync ( _
	inputText As String, _
	compareOptions As CompareOptions _
)
Visual Basic (Usage)
Dim instance As SpeechRecognitionEngine
Dim inputText As String
Dim compareOptions As CompareOptions

instance.EmulateRecognizeAsync(inputText, _
	compareOptions)
C#
public void EmulateRecognizeAsync(
	string inputText,
	CompareOptions compareOptions
)

Parameters

inputText
Type: System..::..String

The input phrase for the recognition operation.

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.

Remarks

The speech recognizer raises the SpeechDetected, SpeechHypothesized, SpeechRecognitionRejected, and SpeechRecognized events as if the recognition operation is not emulated. When the recognizer completes the asynchronous recognition operation, it raises the EmulateRecognizeCompleted event.

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

Emulated recognition ignores new lines and extra white space and treats punctuation literally, rather than letting it define phrases.

Examples

 Copy imageCopy Code
private void EmulateTextBox_KeyPress(object sender, KeyPressEventArgs eventArgs) 
{
  if ((Keys)eventArgs.KeyChar == Keys.Enter) 
  {
    _recognitionEngine.EmulateRecognizeAsync(_emulateTextBox.Text);

  }
}

// Emulate a button click in the emulateTextBox.
private void _emulateButton_Click(object sender, EventArgs e) 
{
  _recognitionEngine.EmulateRecognizeAsync(_emulateTextBox.Text, System.Globalization.CompareOptions.IgnoreCase);
}

See Also