Choices Constructor

Choices Constructor

 

Initializes a new instance of the Choices class.

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

NameDescription
System_CAPS_pubmethodChoices()

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

System_CAPS_pubmethodChoices(GrammarBuilder[])

Initializes a new instance of the Choices class from an array containing one or more GrammarBuilder objects.

System_CAPS_pubmethodChoices(String[])

Initializes a new instance of the Choices class from an array containing one or more String objects.

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.

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;
}
Return to top
Show:
© 2016 Microsoft