Compartilhar via


Note

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

GrammarBuilder.DebugShowPhrases Property

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

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

Syntax

'Declaration
Public ReadOnly Property DebugShowPhrases As String
    Get
'Usage
Dim instance As GrammarBuilder
Dim value As String

value = instance.DebugShowPhrases
public string DebugShowPhrases { get; }

Property Value

Type: System.String
The current content and structure of the GrammarBuilder.

Examples

The following example is part of a console application for choosing origin and destination cities for a flight. The grammar recognizes phrases such as "I want to fly from Miami to Chicago." The grammar includes SemanticResultValue objects that assign airport codes to cities, and SemanticResultKey objects that distinguish between the origin and destination cities.

Using DebugShowPhrases to output the structure of the grammar produces the following results:

"I want to fly from origin=[[Chicago {ORD},Boston{BOS},Miami {MIA},Dallas {DFW}]] to destination=[[Chicago {ORD},Boston {BOS},Miami {MIA},Dallas {DFW}]]"
public static Grammar bookFlight()
{
  // Create GrammarBuilder objects and append SemanticResultValue objects 
  // that contain cities and airport codes.
  GrammarBuilder chicago = new GrammarBuilder();
  chicago.Append(new SemanticResultValue("Chicago", "ORD"));

  GrammarBuilder boston = new GrammarBuilder();
  boston.Append(new SemanticResultValue("Boston", "BOS"));

  GrammarBuilder miami = new GrammarBuilder();
  miami.Append(new SemanticResultValue("Miami", "MIA"));

  GrammarBuilder dallas = new GrammarBuilder();
  dallas.Append(new SemanticResultValue("Dallas", "DFW"));

  // Create a Choices object and add the cities using implicit 
  // conversion from SemanticResultValue to GrammarBuilder.
  Choices cities = new Choices();
  cities.Add(new Choices(new GrammarBuilder[] { chicago, boston, miami, dallas }));

  // Build the phrase and add SemanticResultKeys.
  GrammarBuilder chooseCities = new GrammarBuilder();
  chooseCities.Append("I want to fly from");
  chooseCities.Append(new SemanticResultKey("origin", cities));
  chooseCities.Append("to");
  chooseCities.Append(new SemanticResultKey("destination", cities));

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

  // Build a Grammar object from the GrammarBuilder.
  Grammar bookFlight = new Grammar(chooseCities);
  bookFlight.Name = "Book Flight";

  return bookFlight;
}

See Also

Reference

GrammarBuilder Class

GrammarBuilder Members

Microsoft.Speech.Recognition Namespace