Choices Constructor

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

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

Overload List

  NameDescription
Public methodChoices()()()()Initializes a new instance of the Choices class that contains an empty set of alternatives.
Public methodChoices(array<String>[]()[][])Initializes a new instance of the Choices class from an array containing one or more String objects.
Public methodChoices(array<GrammarBuilder>[]()[][])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".

 Copy imageCopy Code
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