Grammar Constructor

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Initializes a new instance of the Grammar class.

Overload List

  NameDescription
Public methodGrammar(Stream)Initializes a new instance of the Grammar class from a Stream.
Public methodGrammar(String)Initializes a new instance of the Grammar class from a file.
Public methodGrammar(GrammarBuilder)Initializes a new instance of the Grammar class from a GrammarBuilder object.
Public methodGrammar(GrammarInfo)Creates a new instance of the Grammar class from a GrammarInfo instance.
Public methodGrammar(SrgsDocument)Initializes a new instance of the Grammar class from an SrgsDocument object.
Public methodGrammar(Stream, String)Initializes a new instance of the Grammar class from a Stream and specifies a root rule.
Public methodGrammar(String, String)Initializes a new instance of the Grammar class from a file and specifies a root rule.
Public methodGrammar(SrgsDocument, String)Initializes a new instance of a Grammar class from an SrgsDocument object and specifies a root rule.
Public methodGrammar(Stream, String, Uri)Initializes a new instance of the Grammar class from a stream, specifies a root rule, and defines a base Uniform Resource Identifier (URI) to resolve relative rule references.
Public methodGrammar(String, String, Uri)Initializes a new instance of the Grammar class from a file, specifies a root rule, and defines a base Uniform Resource Identifier (URI) to resolve relative rule references.
Public methodGrammar(SrgsDocument, String, Uri)Initializes a new instance of a Grammar class from an SrgsDocument object, specifies a root rule, and defines a base Uniform Resource Identifier (URI) to resolve relative rule references.
Top

Remarks

You can use a Grammar constructor to create a Grammar instance from a GrammarBuilder or SrgsDocument object, or from a file or a Stream that contains a description of a grammar in a supported format. Supported formats include the following:

Grammar constructors that accept XML-format grammar files in their arguments compile the XML grammars to a binary format to optimize them for loading and consumption by a speech recognition engine. You can reduce the amount of time required to construct a Grammar object from an XML-format grammar by compiling the grammar in advance, using one of the Compile()()()() methods.

A speech recognition grammar can define a root rule. To create a Grammar object that specifies which rule to use as its root rule, use a constructor that accepts the ruleName parameter.

To create a Grammar object that specifies a base URI to resolve relative rule references, use a constructor that takes the baseUri parameter.

Specification of parameters during construction is also provided to support the inclusion of scripts in loaded grammars.

NoteNote

It is a best practice to verify the safety of any URI or DLL used to build a Grammar object.

The Microsoft Speech Platform SDK 11 provides security for applications constructing a Grammar instance from a DLL or from a grammar that supports scripting.

Scripts in Grammar objects are always run as if downloaded from a web page in the Internet Zone. The Common Language Runtime (CLR) isolates any DLL loaded to obtain a grammar definition.

See Also