Share via


Note

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

GrammarBuilder.Append Method (String, SubsetMatchingMode)

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

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

Syntax

'Declaration
Public Sub Append ( _
    phrase As String, _
    subsetMatchingCriteria As SubsetMatchingMode _
)
'Usage
Dim instance As GrammarBuilder
Dim phrase As String
Dim subsetMatchingCriteria As SubsetMatchingMode

instance.Append(phrase, subsetMatchingCriteria)
public void Append(
    string phrase,
    SubsetMatchingMode subsetMatchingCriteria
)

Parameters

Remarks

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 Use a String to Create a GrammarBuilder (Microsoft.Speech).

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

Examples

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();
}

See Also

Reference

GrammarBuilder Class

GrammarBuilder Members

Append Overload

Microsoft.Speech.Recognition Namespace