Note

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

SrgsDocument Constructor (GrammarBuilder)

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

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

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

Parameters

Exceptions

Exception Condition
ArgumentNullException

The value of builder is a 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.

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

Reference

SrgsDocument Class

SrgsDocument Members

SrgsDocument Overload

Microsoft.Speech.Recognition.SrgsGrammar Namespace