Compartilhar via


Note

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

SetMinimum and Maximum Repeat Values (Microsoft.Speech)

You can use GrammarBuilder to create a grammar element that specifies a minimum repeat value and a maximum repeat value for successful recognition. A minimum repeat value of zero indicates that the element is optional. If this value is combined with a maximum repeat value of one, the element can be spoken at most one time. The minimum repeat count must be zero or larger and the maximum repeat count must be at least as large as the minimum repeat count.

To create a GrammarBuilder instance with repeat values, use one of the following constructors:

  • GrammarBuilder(GrammarBuilder, Int32, Int32)

  • GrammarBuilder(String, Int32, Int32)

The first of these constructors takes an existing GrammarBuilder instance as its first argument, and the minimum and maximum repeat counts, respectively. The second constructor takes a word or phrase as its first argument, and the minimum and maximum repeat counts.

You can also use the following methods on the GrammarBuilder class to assign minimum and maximum repeat counts:

See Also

Concepts

Create Grammars Using GrammarBuilder (Microsoft.Speech)