You can use a Choices instance to represent an element in a phrase that can have one of several values. You incorporate each of the possible values into the Choices instance.
The following example creates a simple GrammarBuilder grammar that recognizes "The card suit is <suit>"; where <suit> is a placeholder that can be replaced by "hearts", "diamonds", "clubs", or "spades" during speech recognition. The possible values for <suit> are created by the Choices(array<String>[]()[][]) constructor, which takes an array of String objects as its parameter. The example uses the Append(Choices) method to add the Choices object to the grammar.
C# | Copy Code |
---|---|
GrammarBuilder gb = new GrammarBuilder("The card suit is"); Choices suits = new Choices(new string[] {"hearts", "diamonds", "clubs", "spades"}); gb.Append(suits); |
A Choices instance is similar to the SRGS one-of Element (Microsoft.Speech), as defined in the Speech Recognition Grammar Specification (SRGS) Version 1.0, and an SrgsOneOf instance.