Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

Microsoft Speech Platform

ISpRecoGrammar

The ISpRecoGrammar interface enables applications to manage the words and phrases that the speech recognition (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.

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

Methods in Vtable Order

ISpRecoGrammar Methods Description
ISpGrammarBuilder interface Inherits from ISpGrammarBuilder and all those methods are accessible from an ISpRecoGrammar object.
GetGrammarId Retrieves the grammar identifier associated with the application.
GetRecoContext Retrieves the context object that created this grammar.
LoadCmdFromFile Loads a command and control grammar from a file.
LoadCmdFromObject Loads a command and control grammar from a COM object.
LoadCmdFromResource Loads a command and control grammar from a Win32 resource.
LoadCmdFromMemory Loads a command and control grammar from memory.
LoadCmdFromProprietaryGrammar Loads an engine proprietary format command and control grammar.
SetRuleState Activates or deactivates a rule by its rule name.
SetRuleIdState Activates or deactivates a rule by its rule ID.
SetWordSequenceData Sets a word sequence buffer in the SR engine.
SetTextSelection Sets the current text selection and insertion point information.
IsPronounceable Determines if the word has a pronunciation.
SetGrammarState Sets the grammar state.
SaveCmd Allows applications using dynamic grammars to save the current grammar state to a stream.
GetGrammarState Retrieves recognition grammar state information.