Note
Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.
Microsoft Speech Platform
ISpGrammarBuilder
Use the methods of the ISpGrammarBuilder interface to programmatically create and modify grammars.
When To Use
Applications should use the ISpGrammarBuilder interface to change and save dynamically loaded grammars (see ISpRecoGrammar).
Methods in Vtable Order
ISpGrammarBuilder Methods | Description |
---|---|
ResetGrammar | Clears all grammar rules (un-defines them) and resets the grammar's language to NewLanguage. |
GetRule | Retrieves a grammar rule's initial state information (and defines the rule if requested). |
ClearRule | Removes all of the grammar rule information except for the rule's initial state handle. |
CreateNewState | Creates a new state in the same grammar rule as hState. |
AddWordTransition | Adds a word or a sequence of words to the grammar. |
AddRuleTransition | Adds a rule (reference) transition from one grammar rule to another. |
AddResource | Adds a resource (name and string value) to the grammar rule specified in hRuleState. |
Commit | Performs consistency checks of the grammar structure, creates the serialized format, saves the grammar structure, reloads the grammar structure to the stream provided by SetSaveObjects, or reloads it into the SR engine. |
Remarks
See Using IspGrammarBuilder to Author Grammars for an example that creates a grammar programmatically, and Grammar Authoring Overview for more information about authoring grammars.