ISpRecoGrammar (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3


The ISpRecoGrammar interface enables applications to manage the words and phrases that the SR engine will recognize.

A single SpRecognizer object can have multiple SpRecoContext objects associated with it. And similarly, a single SpRecoContext object can have multiple SpRecoGrammar objects associated with it. Using a one-to-many relationship with SpRecoContext objects and SpRecoGrammar objects allows applications to separate types of recognizable phrases and content into separate objects for clearer application logic. Each SpRecoGrammar object can also have a context-free grammar (CFG) and a dictation grammar loaded simultaneously (e.g., use the CFG if possible, but back off to dictation if CFG fails to parse).

See Designing Grammar Rules for examples of how to create context-free grammars.

Methods in Vtable Order

ISpRecoGrammar MethodsDescription
ISpGrammarBuilder interfaceInherits from ISpGrammarBuilder and all those methods are accessible from an ISpRecoGrammar object.
GetGrammarIdRetrieves the grammar identifier associated with the application.
GetRecoContextRetrieves the context object that created this grammar.
LoadCmdFromFileLoads a command and control grammar from a file.
LoadCmdFromObjectLoads a command and control grammar from a COM object.
LoadCmdFromResourceLoads a command and control grammar from a Win32 resource.
LoadCmdFromMemoryLoads a command and control grammar from memory.
LoadCmdFromProprietaryGrammarLoads an engine proprietary format command and control grammar.
SetRuleStateActivates or deactivates a rule by its rule name.
SetRuleIdStateActivates or deactivates a rule by its rule ID.
LoadDictationLoads and initializes a dictation topic.
UnloadDictationUnloads the active dictation topic from the grammar.
SetDictationStateSets a dictation state to active or inactive.
SetWordSequenceDataSets a word sequence buffer in the SR engine.
SetTextSelectionSets the current text selection and insertion point information.
IsPronounceableDetermines if the word has a pronunciation.
SetGrammarStateSets the grammar state.
SaveCmdAllows applications using dynamic grammars to save the current grammar state to a stream.
GetGrammarStateRetrieves recognition grammar state information.