Interface: ISpeechRecoContext
State Property
The State property gets or sets the active state of the recognition context.
The entire grammar associated with the recognition context can be disabled or enabled. The individual rule states of the grammar are unaffected otherwise. These conditions allow the application to control the state of the grammars at a high level. For example, if the window loses the current focus, the recognition context (s) associated with that window may be disabled if recognitions are not needed. Likewise, when the window regains the focus, all the recognition contexts may be enabled.
Syntax
Set: | SpeechRecoContext.State = SpeechRecoContextState |
Get: | SpeechRecoContextState = SpeechRecoContext.State |
Parts
- SpeechRecoContext
- The owning object.
- SpeechRecoContextState
-
Set: A SpeechRecoContextState variable that sets the property.
Get: A SpeechRecoContextState variable that gets the property.
Example
The following code snippet demonstrates disabling and enabling a command and control grammar. The sample opens a configuration file, sol.xml, and sets one rule, identified as 101, as active. The application could continue and disable the entire grammar so that no recognitions are possible based on that grammar. Later, when the application enables the grammar, the same single rule (101) would still be active.
Set RC = New SpSharedRecoContext
Set myGrammar = RC.CreateGrammar
myGrammar.CmdLoadFromFile "sol.xml", SLODynamic
myGrammar.CmdSetRuleIdState 101, SGDSActive
'Possible program execution could go here
RC.State = SRCS_Disabled
'Possible program execution could go here
RC.State = SRCS_Enabled