Choices コンストラクター

定義

Choices クラスの新しいインスタンスを初期化します。

オーバーロード

名前 説明
Choices()

空の代替セットを含む Choices クラスの新しいインスタンスを初期化します。

Choices(GrammarBuilder[])

1 つ以上のChoices オブジェクトを含む配列から、GrammarBuilder クラスの新しいインスタンスを初期化します。

Choices(String[])

1 つ以上のChoices オブジェクトを含む配列から、String クラスの新しいインスタンスを初期化します。

次の例では、 Choices オブジェクトを使用して、代替の 2 つのリストを作成します。

最初の Choices オブジェクトは、 String オブジェクトの配列から構築されます。 もう 1 つの Choices オブジェクトは、キャストによって暗黙的に変換された GrammarBuilder オブジェクトの配列から構築されます。

この例では、 GrammarBuilder オブジェクトを使用して、 Choices オブジェクトと 2 つの追加の文字列を使用してフレーズをアセンブルします。この文字列を使用して、"Call [contactlList] on [phoneType] phone" (携帯電話で Jane を呼び出す) などの形式で音声入力を認識できます。

public GrammarBuilder ChoicesConstructor2 ()
{
    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;
}

注釈

パラメーターなしのコンストラクター (空のオブジェクトを返します)、Choices オブジェクトのグループ、または一連のString オブジェクトを使用して、GrammarBuilder オブジェクトを構築できます。

GrammarBuilder オブジェクトはSemanticResultValueSemanticResultKeyからの暗黙的な変換をサポートしているため、キャストを使用してこれらのオブジェクトの配列からChoicesを構築できます。

Choices()

ソース:
Choices.cs
ソース:
Choices.cs
ソース:
Choices.cs
ソース:
Choices.cs

空の代替セットを含む Choices クラスの新しいインスタンスを初期化します。

public:
 Choices();
public Choices();
Public Sub New ()

次の例では、 Choices オブジェクトと GrammarBuilder オブジェクトを使用して、"Call Anne on her cell" や "Call James on his work phone" などの音声入力を認識するために使用できるフレーズを作成します。 この例では、 Choices からの暗黙的なキャストと String を使用して GrammarBuilderします。

public Grammar CreatePhonePhrase()
{

  // Create alternatives for female names and add a phrase.
  GrammarBuilder females = new Choices(new string[] { "Anne", "Mary" });
  females.Append("on her");

  // Create alternatives for male names and add a phrase.
  GrammarBuilder males = new Choices(new string[] { "James", "Sam" });
  males.Append("on his");

  // Create a Choices object that contains an array of alternative
  // GrammarBuilder objects.
  Choices people = new Choices();
  people.Add(new Choices(new GrammarBuilder[] {females, males}));

  // Create a Choices object that contains a set of alternative phone types.
  Choices phoneType = new Choices();
  phoneType.Add(new string[] { "cell", "home", "work" });

  // Construct the phrase.
  GrammarBuilder gb = new GrammarBuilder();
  gb.Append("call");
  gb.Append(people);
  gb.Append(phoneType);
  gb.Append(new GrammarBuilder("phone"), 0, 1);

  return new Grammar(gb);
}

注釈

このコンストラクターは、有効な空の代替セットを返します。 任意の Add メソッドを使用して代替手段を追加できます。

こちらもご覧ください

適用対象

Choices(GrammarBuilder[])

ソース:
Choices.cs
ソース:
Choices.cs
ソース:
Choices.cs
ソース:
Choices.cs

1 つ以上のChoices オブジェクトを含む配列から、GrammarBuilder クラスの新しいインスタンスを初期化します。

public:
 Choices(... cli::array <System::Speech::Recognition::GrammarBuilder ^> ^ alternateChoices);
public Choices(params System.Speech.Recognition.GrammarBuilder[] alternateChoices);
new System.Speech.Recognition.Choices : System.Speech.Recognition.GrammarBuilder[] -> System.Speech.Recognition.Choices
Public Sub New (ParamArray alternateChoices As GrammarBuilder())

パラメーター

alternateChoices
GrammarBuilder[]

代替のセットを含む配列。

次の例では、 Choices オブジェクトと GrammarBuilder オブジェクトを使用して、"Call Anne on her cell" や "Call James on his work phone" などの語句の Grammar を作成します。 この例では、 Choices からの暗黙的なキャストと String を使用して GrammarBuilderします。

public Grammar CreatePhonePhrase()
{

  // Create alternatives for female names and add a phrase.
  GrammarBuilder females = new Choices(new string[] { "Anne", "Mary" });
  females.Append("on her");

  // Create alternatives for male names and add a phrase.
  GrammarBuilder males = new Choices(new string[] { "James", "Sam" });
  males.Append("on his");

  // Create a Choices object that contains an array of alternative
  // GrammarBuilder objects.
  Choices people = new Choices();
  people.Add(new Choices(new GrammarBuilder[] {females, males}));

  // Create a Choices object that contains a set of alternative phone types.
  Choices phoneType = new Choices();
  phoneType.Add(new string[] { "cell", "home", "work" });

  // Construct the phrase.
  GrammarBuilder gb = new GrammarBuilder();
  gb.Append("call");
  gb.Append(people);
  gb.Append(phoneType);
  gb.Append(new GrammarBuilder("phone"), 0, 1);

  return new Grammar(gb);
}

注釈

GrammarBuilderの各alternateChoicesは、1 つの代替手段を定義します。 alternateChoicesが空の配列の場合、コンストラクターは空の代替セットを返します。 任意の Add メソッドを使用して代替手段を追加できます。

コンストラクターは、ArgumentNullExceptionalternateChoicesされたとき、または配列要素のいずれかがnullされたときに、nullをスローします。

GrammarBuilder クラスは、キャストを適切に使用して、ChoicesSemanticResultValue、およびSemanticResultKeyオブジェクトをGrammarBuilder インスタンスに暗黙的に変換するためのサポートを提供するため、このコンストラクターを使用して、これらのオブジェクトの任意の組み合わせのリストからChoices オブジェクトを作成することもできます。

こちらもご覧ください

適用対象

Choices(String[])

ソース:
Choices.cs
ソース:
Choices.cs
ソース:
Choices.cs
ソース:
Choices.cs

1 つ以上のChoices オブジェクトを含む配列から、String クラスの新しいインスタンスを初期化します。

public:
 Choices(... cli::array <System::String ^> ^ phrases);
public Choices(params string[] phrases);
new System.Speech.Recognition.Choices : string[] -> System.Speech.Recognition.Choices
Public Sub New (ParamArray phrases As String())

パラメーター

phrases
String[]

代替のセットを含む配列。

次の例では、 Choices オブジェクトと GrammarBuilder オブジェクトを使用して、"Call Anne on her cell" や "Call James on his work phone" などの語句の Grammar を作成します。 この例では、 Choices からの暗黙的なキャストと String を使用して GrammarBuilderします。

public Grammar CreatePhonePhrase()
{

  // Create alternatives for female names and add a phrase.
  GrammarBuilder females = new Choices(new string[] { "Anne", "Mary" });
  females.Append("on her");

  // Create alternatives for male names and add a phrase.
  GrammarBuilder males = new Choices(new string[] { "James", "Sam" });
  males.Append("on his");

  // Create a Choices object that contains an array of alternative
  // GrammarBuilder objects.
  Choices people = new Choices();
  people.Add(new Choices(new GrammarBuilder[] {females, males}));

  // Create a Choices object that contains a set of alternative phone types.
  Choices phoneType = new Choices();
  phoneType.Add(new string[] { "cell", "home", "work" });

  // Construct the phrase.
  GrammarBuilder gb = new GrammarBuilder();
  gb.Append("call");
  gb.Append(people);
  gb.Append(phoneType);
  gb.Append(new GrammarBuilder("phone"), 0, 1);

  return new Grammar(gb);
}

注釈

Stringの各phrasesは、1 つの代替手段を定義します。 音声認識エンジンは、文字列配列内の任意の項目を使用して、音声入力と一致させることができます。 phrasesが空の配列の場合、コンストラクターは空の代替セットを返します。 任意の Add メソッドを使用して代替手段を追加できます。

コンストラクターは、ArgumentNullExceptionphrasesされたとき、または配列要素のいずれかがnullされたときに、nullをスローします。 コンストラクターは、配列内の要素が空の文字列 ("") の場合、 ArgumentException をスローします。

こちらもご覧ください

適用対象