ISpeechRecoGrammar Interface (SAPI 5.4)

Speech API 5.4
Microsoft Speech API 5.4


The ISpeechRecoGrammar automation interface enables applications to manage the words and phrases for the SR engine.

A single SpRecognizer object can be associated with multiple SpRecoContext objects. Similarly, a single SpRecoContext object can be associated with multiple ISpRecoGrammar objects. This allows designers to create applications containing several grammars, each of which is specialized for a different type of recognition. Each ISpRecoGrammar object can contain both a context-free grammar (CFG) and a dictation grammar simultaneously.

Automation Interfaces

The ISpeechRecoGrammar automation interface contains the following elements:

Id PropertyReturns the Id assigned to the grammar when it was created.
RecoContext PropertyReturns the RecoContext object that created this grammar.
Rules PropertyReturns the collection of grammar rules in the RecoGrammar.
State PropertyGets and sets the operational status of the speech grammar.
CmdLoadFromFile MethodLoads a command and control grammar from the specified file.
CmdLoadFromMemory MethodLoads a compiled speech grammar from memory.
CmdLoadFromObject MethodLoads a speech grammar from a COM object.
CmdLoadFromProprietaryGrammar MethodLoads a proprietary speech grammar.
CmdLoadFromResource MethodLoads a command and control grammar from a Win32 resource.
CmdSetRuleIdState MethodActivates or deactivates a rule by its rule ID.
CmdSetRuleState MethodActivates or deactivates a rule by its rule name.
DictationLoad MethodLoads a dictation topic into the grammar.
DictationSetState MethodSets the dictation topic state.
DictationUnload MethodUnloads the active dictation topic from the grammar.
IsPronounceable MethodDetermines if a word has a pronunciation.
Reset MethodClears all grammar rules and resets the grammar's language to NewLanguage.
SetTextSelection MethodSets the range of text selection information in a word sequence data buffer.
SetWordSequenceData MethodDefines a word sequence data buffer for use by the SR engine.