Grammar Constructor (GrammarBuilder^)
.NET Framework (current version)
Initializes a new instance of the Grammar class from a GrammarBuilder object.
Assembly: System.Speech (in System.Speech.dll)
Parameters
- builder
-
Type:
System.Speech.Recognition::GrammarBuilder^
An instance of GrammarBuilder that contains the constraints for the speech recognition grammar.
For more information about using the GrammarBuilder class to define a grammar, see Create Grammars Using GrammarBuilder.
The following example creates a speech recognition grammar using Choices and GrammarBuilder objects. The Grammar constructor creates a Grammar object from the GrammarBuilder object.
// Create a grammar using a GrammarBuilder and return the new grammar. private static Grammar CreateGrammarBuilderGrammar() { GrammarBuilder builder = new GrammarBuilder(); Choices cityChoice = new Choices (new string[] {"Seattle", "New York", "Miami", "Los Angeles"}); builder.Append("I would like to fly from"); builder.Append(cityChoice); builder.Append("to"); builder.Append(cityChoice); Grammar citiesGrammar = new Grammar(builder); citiesGrammar.Name = "GrammarBuilder Cities Grammar"; return citiesGrammar; }
.NET Framework
Available since 3.0
Available since 3.0
Show: