SpeechRecognitionEngine.EmulateRecognize Method
Provides support for synchronous simulation of audio input to support testing and debugging.
This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.
| Name | Description | |
|---|---|---|
|
EmulateRecognize(String) | Synchronously simulate audio input to the Windows Desktop Speech Technology recognition engine with a String. |
|
EmulateRecognize(RecognizedWordUnit[], CompareOptions) | Synchronously simulate audio input to the Windows Desktop Speech Technology recognition engine with an array of RecognizedWordUnit objects and specified case sensitivity. |
|
EmulateRecognize(String, CompareOptions) | Synchronously simulate audio input to the Windows Desktop Speech Technology recognition engine with a String and specified case sensitivity. |
The EmulateRecognize object allows for testing and debugging of the applications and grammars using synchronous recognition technology without dependency on a system’s audio input technology.
Instead of using audio information as input, the EmulateRecognize methods can accept a string or an array of RecognizedWordUnit objects as an argument.
Applications obtain results from synchronous emulation of speech recognition either by the instance of RecognitionResult returned by EmulateRecognize, or by handling the events that would be produced by actual audio input: SpeechDetected, SpeechHypothesized, SpeechRecognitionRejected, SpeechRecognized.
Note:
|
|---|
|
When emulating recognition the Audio property on a RecognitionResult() object will be null. |
Emulated recognition ignores new lines and extra white space and treats punctuation literally, rather than letting it define phrases.
Asynchronous simulation can be obtained through EmulateRecognizeAsync.
In the following example, an application obtains text input through a Textbox, and uses it to emulate speech input.
private void EmulateTextBox_KeyPress(object sender, KeyPressEventArgs eventArgs) {
if ((Keys)eventArgs.KeyChar == Keys.Enter) {
RecognitionResult result = _recognitionEngine.EmulateRecognize(_emulateTextBox.Text);
}
}
// Emulate when Button is pressed in the emulateTextBox.
private void _emulateButton_Click(object sender, EventArgs e) {
RecognitionResult result = _recognitionEngine.EmulateRecognize(_emulateTextBox.Text);
}
Note: