ISpRecognizer::EmulateRecognition (SAPI 5.4)

Microsoft Speech API 5.4

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
S_OK
S_FALSE
SP_NO_PARSE_FOUND
SP_NO_RULES_ACTIVE
E_POINTER
SPERR_UNINITIALIZED
E_OUTOFMEMORY
FAILED(hr)

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. 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.