ISpRecognizer::EmulateRecognition (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3


ISpRecognizer::EmulateRecognition emulates a recognition from a specified phrase rather than from spoken content. 

HRESULT EmulateRecognition(
   ISpPhrase   *pPhrase


[in] The phrase to emulate.

Return values

S_OKFunction completed successfully.
SP_NO_PARSE_FOUNDFunction completed successfully but the phrase does not parse through any active rule.
SP_NO_RULES_ACTIVEFunction completed successfully but there are no active rules to parse.
E_POINTERppCoMemPhrase is invalid or bad.
SPERR_UNINITIALIZEDPhrase is uninitialized.
E_OUTOFMEMORYExceeded available memory.
FAILED(hr)Appropriate error message.


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. The phrase can be generated by creating a phrase builder object and then adding elements representing the text to it. 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.