Share via


ISpRecognizer::SetRecoState (Windows CE 5.0)

Send Feedback

This method sets the state of the recognizer to reflect the SR engine state. The default state of an engine is SPRST_ACTIVE, which indicates that SAPI will start recognition whenever there are active rules and stop recognition when there are none. This is the typical state to be used by most applications. In the shared recognizer case, if an application has no active rules it will receive no recognition events, and if other applications have active rules they will receive relevant events.

The other states have more specialized uses:

SPRST_INACTIVE turns off audio and recognition, even if there are rules active. The audio device will be closed in this state. Typically, an application should not set the state to SPRST_INACTIVE because when using the shared engine recognition will be stopped for all applications, not just this one. An application can easily disable recognition on its contexts by calling ISpRecoContext::SetContextState.

SPRST_ACTIVE_ALWAYS makes audio input occur even if there are no active rules. This can be useful if an application wishes to receive audio level events but does not want to do recognition.

SPRST_INACTIVE_WITH_PURGE inactivates the engine and makes it complete processing as quickly as possible. The SPRST_INACTIVE state will stop recognition but the engine will complete processing all the data that is currently buffered. This state can be used if it is necessary to stop the engine immediately. This state should be used with care because it will affect all applications in the shared case.

When using the shared recognizer, the recognizer state is a global setting. If one application changes the recognizer state, then it will affect all other applications connected to the shared recognizer. For this reason, applications using a shared recognizer should take great caution before calling SetRecoState.

Changing the recognition state leads to a SPEI_RECO_STATE_CHANGE event being fired to all interested recognition contexts.

HRESULT SetRecoState(SPRECOSTATE NewState);

Parameters

  • NewState
    [in] The speech recognition state to set. Possible values are defined for the SPRECOSTATE enumeration.

Return Values

The following table shows the possible return values.

Value Description
S_OK Function completed successfully.
FAILED(hr) Appropriate error message.
E_INVALIDARG One or more arguments are invalid.

Requirements

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

See Also

ISpRecognizer | SAPI Interfaces

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.