Note
Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.
Microsoft.Speech.Recognition.SrgsGrammar Namespace
With the members of the Microsoft.Speech.Recogntion.SRGSGrammar namespace, you can programmatically create grammars that comply with the W3C Speech Recognition Grammar Specification Version 1.0 (SRGS).
To create an SRGS grammar programmatically, you construct an empty SrgsDocument instance and add instances of classes that represent SRGS elements. The SrgsItem, SrgsOneOf, SrgsRule, SrgsRuleRef, SrgsSemanticInterpretationTag, and SrgsToken classes represent elements defined in the SRGS specification. Some of the properties of the SrgsDocument class represent attributes in the SRGS specification, such as Root, Mode, Culture, and XmlBase. See SRGS Grammar XML Reference (Microsoft.Speech) for a reference to the elements and attributes of the SRGS specification as supported by the Microsoft Speech Platform SDK 11.
To add a grammar rule to a SrgsDocument, use the Add(SrgsElement) method of the SrgsRule class. You can modify the text within an SRGS element using the Text property of a SrgsText instance.
See Create Grammars Using SrgsGrammar (Microsoft.Speech) in the Microsoft Speech Programming Guide for more information and examples.
You can also construct SrgsDocument instances from existing SRGS-compliant XML grammar files, from an instance of SrgsRule, or from an instance of GrammarBuilder.
You can use the methods of the SrgsGrammarCompiler class to compile completed SrgsDocument objects for into a binary format that can be more efficiently consumed by a speech recognition engine.
Grammars created with members of the Microsoft.Speech.Recognition.SrgsGrammar namespace can be used by constructors of the Grammar class to create Grammar objects.
Classes
Class | Description | |
---|---|---|
MssGrammarCompiler | Represents a compiler for speech recognition grammars. | |
SrgsDocument | Defines a design-time object that is used to build strongly typed runtime grammars that conform to the Speech Recognition Grammar Specification (SRGS) Version 1.0. | |
SrgsElement | Defines the base class for classes in the Microsoft.Speech.Recognition.SrgsGrammar namespace that correspond to the elements in an SRGS grammar. | |
SrgsGrammarCompiler | Compiles SrgsDocument and XML-format grammar files into binary grammar files with the .cfg extension and sends the output to a stream. | |
SrgsItem | Represents a grammar element that contains phrases or other entities that a user can speak to produce a successful recognition. | |
SrgsOneOf | Represents a list of alternative words or phrases, any one of which may be used to match speech input. | |
SrgsRule | Represents a grammar rule. | |
SrgsRuleRef | Represents the grammar element that specifies a reference to a rule. | |
SrgsRulesCollection | Represents a collection of SrgsRule objects. | |
SrgsSemanticInterpretationTag | Represents a tag that contains ECMAScript that is run when the rule is matched. | |
SrgsText | Represents the textual content of grammar elements defined by the World Wide Web Consortium (W3C) Speech Recognition Grammar Specification (SRGS) Version 1.0. | |
SrgsToken | Represents a word or short phrase that can be recognized. |
Enumerations
Enumeration | Description | |
---|---|---|
SrgsGrammarMode | Indicates the type of input that the grammar, defined by the SrgsDocument, will match. | |
SrgsPhoneticAlphabet | Enumerates the supported phonetic alphabets. | |
SrgsRuleScope | Enumerates values for the scope of a SrgsRule object. |