Share via


Note

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

Choices Constructor

Include Protected Members
Include Inherited Members

Initializes a new instance of the Choices class that contains an empty set of alternatives.

Overload List

  Name Description
Public method Choices() Initializes a new instance of the Choices class that contains an empty set of alternatives.
Public method Choices([]) Initializes a new instance of the Choices class from an array containing one or more String objects.
Public method Choices([]) Initializes a new instance of the Choices class from an array containing one or more GrammarBuilder objects.

Top

Remarks

You can construct a Choices object using a default constructor (which returns an empty object), from a group of String objects, or a from set of GrammarBuilder objects.

Because the GrammarBuilder object supports implicit conversion from SemanticResultValue and SemanticResultKey, a Choices can be constructed from an array of these objects using a cast.

Examples

The following example uses Choices objects to create two lists of alternatives.

The first Choices object is constructed from an array of String objects. The other Choices object is constructed from an array of GrammarBuilder objects which have been implicitly converted by a cast.

The example uses a GrammarBuilder object to assemble a phrase, using the Choices objects and two additional strings, that can be used to recognize speech input in the form of "Call [contactlList] on [phoneType] phone" , for example "Call Jane on cell phone".

public GrammarBuilder ChoicesContructor2 ()
{
    GrammarBuilder gb = new GrammarBuilder ();
    Choices phoneType = new Choices (new string[] {"cell", "home", "work"});
    Choices contactList = new Choices (new GrammarBuilder[] {(GrammarBuilder) "Mark", (GrammarBuilder) "Jane", (GrammarBuilder) "Frank"});
    gb.Append ("Call");
    gb.Append (contactList);
    gb.Append ("on");
    gb.Append (phoneType);
    gb.Append ("phone");
    return gb;
}

See Also

Reference

Choices Class

Choices Members

Microsoft.Speech.Recognition Namespace

GrammarBuilder

Grammar