GrammarBuilder.DebugShowPhrases Property

 

Gets a string that shows the contents and structure of the grammar contained by the GrammarBuilder.

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

public string DebugShowPhrases { get; }

Property Value

Type: System.String

The current content and structure of the GrammarBuilder.

The following example creates a speech recognition grammar for ordering a pizza with up to four toppings. It writes the status of the GrammarBuilder to the console before creating the grammar. This method generates the following output:

  • GrammarBuilder status: I would like a [cheese,mushroom,tomato,onion,anchovy,chic ken,pepperoni] and [cheese,mushroom,tomato,onion,anchovy,chicken,pepperoni] pizza



private static Grammar CreatePizzaGrammar()
{

  // Create a Choices object with alternatives for toppings.
  Choices toppings = new Choices(new string[] {
    "cheese", "mushroom", "tomato", "onion",
    "anchovy", "chicken", "pepperoni"});

  // Create a GrammarBuilder and append the Choices object.
  GrammarBuilder andToppings = new GrammarBuilder("and", 0, 1);
  andToppings.Append(toppings);

  // Construct the phrase.
  GrammarBuilder gb = new GrammarBuilder("I would like a", 0, 1);
  gb.Append(toppings);
  gb.Append(new GrammarBuilder(andToppings, 0, 3));
  gb.Append("pizza");

  // Write the contents and structure of the GrammarBuilder to the console.
  Console.WriteLine("Grammar content and structure: {0}", gb.DebugShowPhrases);

  // Create the Grammar from the GrammarBuilder.
  Grammar grammar = new Grammar(gb);
  grammar.Name = "Pizza Order";

  return grammar;
}

.NET Framework
Available since 3.0
Return to top
Show: