ISpRecognizer::EmulateRecognition

This method emulates a recognition from a specified phrase rather than from spoken content.

This can be used for testing by simulating user speech, and can 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 typical 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 only be produced 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.

HRESULT EmulateRecognition(
  ISpPhrase* pPhrase
);

Parameters

  • pPhrase
    [in] Pointer to an object implementing ISpPhrase that represents the phrase to emulate.

Return Values

The following table shows the possible return values.

Value Description
S_OK Function completed successfully.
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, this method uses 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 (such as <DICTATION/>), the rule recognized at run time may not be consistent.

Requirements

OS Versions: Windows CE .NET 4.1 and later.
Header: Sapi.h, Sapi.idl.
Link Library: Sapilib.lib.

See Also

ISpRecognizer | SAPI Interfaces

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.