ISpRecognizer::EmulateRecognition
ISpRecognizer::EmulateRecognition emulates a recognition from a specified phrase rather than from spoken content.
HRESULT EmulateRecognition(
ISpPhrase *pPhrase
);
Parameters
- pPhrase
- [in] The phrase to emulate.
Return values
Value | Description |
---|---|
S_OK | Function completed successfully. |
S_FALSE | The phrase to be recognized ended before the end of the grammar was reached. |
SP_NO_PARSE_FOUND | Function completed successfully but the phrase does not parse through any active rule. |
SP_NO_RULES_ACTIVE | Function completed successfully but there are no active rules to parse. |
E_POINTER | ppCoMemPhrase is invalid or bad. |
SPERR_UNINITIALIZED | Phrase is uninitialized. |
E_OUTOFMEMORY | Exceeded available memory. |
FAILED(hr) | Appropriate error message. |
Remarks
In the case of ambiguous rules or CFG paths, the ::EmulateRecognition method will return an arbitrary rule or path. For example, if a grammar has two ambiguous rules, the first containing the phrase "a b c", and the second containing only a dictation tag (i.e., <DICTATION/>), the rule recognized at run time may not be consistent.
This method can be used for testing applications that use speech recognition by simulating user speech. It can also be used by applications where users have the option to type or speak a command. See the SDK Sample Simple Recognition (Reco.exe) for the function CreatePhraseFromText as an example of using ISpPhraseBuilder.
All the events will be fired back to the application exactly as if a normal recognition had taken place. The result phrase will have the semantic properties set in the same way a real result would. A recognition event will be produced only if the text actually parses through the active rules (if dictation is active, any text will parse). Another application or ISpRecoContext containing an active rule that can parse the text can receive the emulated recognition.