Note

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

Choices.ToGrammarBuilder Method

Returns a GrammarBuilder object from this Choices object.

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

Syntax

'Declaration
Public Function ToGrammarBuilder As GrammarBuilder
'Usage
Dim instance As Choices
Dim returnValue As GrammarBuilder

returnValue = instance.ToGrammarBuilder()
public GrammarBuilder ToGrammarBuilder()

Return Value

Type: Microsoft.Speech.Recognition.GrammarBuilder
A GrammarBuilder that matches this Choices object.

Remarks

The GrammarBuilder returned by this method is equivalent to one returned by either of the following.

  • Calling the GrammarBuilder constructor with this object as the parameter.

  • Using the implicit or explicit cast of this object to a GrammarBuilder.

Examples

The following example creates a speech recognition grammar for changing the background color.

private Grammar CreateColorChoice()
{

  // Create a Choices object that contains a set of alternative colors.
  Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});

  // Construct the phrase.
  GrammarBuilder gb = new GrammarBuilder();
  gb.Append(new Choices(new string[] {"Set", "Change"}));
  gb.Append("background to");
  gb.Append(colorChoice.ToGrammarBuilder());

  Grammar grammar = new Grammar(gb);
  grammar.Name = "modify background color";

  return grammar;
}

See Also

Reference

Choices Class

Choices Members

Microsoft.Speech.Recognition Namespace

GrammarBuilder

Grammar