Export (0) Print
Expand All

GrammarBuilder.Append Method (String, SubsetMatchingMode)

Appends an element for a subset of a phrase to the current sequence of grammar elements.

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

public void Append(
	string phrase,
	SubsetMatchingMode subsetMatchingCriteria
)

Parameters

phrase
Type: System.String

The sequence of words to append.

subsetMatchingCriteria
Type: System.Speech.Recognition.SubsetMatchingMode

The matching mode the grammar uses to recognize the phrase.

The subset element is added to the end of the current sequence of elements. For more information about building a speech recognition grammar using strings, see Using Strings to Create a GrammarBuilder Grammar.

For detailed information on the use of subset matching modes, see System.Speech.Recognition.SubsetMatchingMode.

The following example creates a speech recognition grammar for each SubsetMatchingMode value. For example, the generated grammar OrderedSubset recognizes the phrases, "three four five" and "one three five", and the grammar Subsequence recognizes the phrase "three four five", but not the phrase, "one three five".

private Grammar[] CreateSubsetMatchTest()
{
  List<Grammar> grammars = new List<Grammar>(4);

  string phrase = "one two three four five six";
  foreach (SubsetMatchingMode mode in
    Enum.GetValues(typeof(SubsetMatchingMode)))
  {
    GrammarBuilder gb = new GrammarBuilder();
    gb.Append(phrase, mode);

    Grammar grammar = new Grammar(gb);
    grammar.Name = mode.ToString();
    grammars.Add(grammar);
  }

  return grammars.ToArray();
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft