SrgsDocument Constructor (GrammarBuilder)

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Initializes a new instance of the SrgsDocument class from a GrammarBuilder object.

Namespace:  Microsoft.Speech.Recognition.SrgsGrammar
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

Visual Basic (Declaration)
Public Sub New ( _
	builder As GrammarBuilder _
)
Visual Basic (Usage)
Dim builder As GrammarBuilder

Dim instance As New SrgsDocument(builder)
C#
public SrgsDocument(
	GrammarBuilder builder
)

Parameters

builder
Type: Microsoft.Speech.Recognition..::..GrammarBuilder

The GrammarBuilder object used to create the SrgsDocument instance.

Exceptions

ExceptionCondition
ArgumentNullException

The value of builder is nullNothingnullptrunita null reference (Nothing in Visual Basic).

Examples

The following example builds a grammar in a GrammarBuilder instance using Choices objects. It then creates an SrgsDocument from the GrammarBuilder object.

C# Copy imageCopy Code
GrammarBuilder builder = null;

// Create new Choices objects and add countries, and create GrammarBuilder objects.
Choices choicesEurope = new Choices(new string[] { "England", "France", "Germany", "Italy" });
GrammarBuilder europe = new GrammarBuilder(choicesEurope);

Choices choicesSAmerica = new Choices(new string[] { "Argentina", "Brazil", "Uruguay" });
GrammarBuilder sAmerica = new GrammarBuilder(choicesSAmerica);

Choices worldCupWinnerChoices = new Choices(new GrammarBuilder[] {choicesEurope, choicesSAmerica});

// Create new GrammarBuilder from a Choices object.
builder = new GrammarBuilder(worldCupWinnerChoices);

// Create an SrgsDocument object from a GrammarBuilder object.
SrgsDocument document = new SrgsDocument(builder);

See Also