Choices 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示語音辨識文法條件約束中的一組替代項。
public ref class Choices
public class Choices
type Choices = class
Public Class Choices
- 繼承
-
Choices
範例
下列範例會建立片語 「Set background to colorChoice」 的語音辨識文法,其中 colorChoice 可以是其中一個定義的色彩。 GrammarBuilder用來定義文法的條件約束。
private Grammar CreateColorGrammar()
{
// Create a Choices object that contains a set of alternative colors.
Choices colorChoice = new Choices(new string[] {"red", "green", "blue"});
colorChoice.Add(new string[] {"cyan", "yellow", "magenta"});
// Construct the phrase.
GrammarBuilder builder = new GrammarBuilder("Set background to");
builder.Append(colorChoice);
// Create a grammar for the phrase.
Grammar colorGrammar = new Grammar(builder);
colorGrammar.Name = "SetBackground";
return colorGrammar;
}
備註
Choices物件代表片語的元件,可以有數個值之一。 從 GrammarBuilder 物件建立語音辨識文法時,請使用這個類別。
例如, Choices 物件可以代表片語中的元件 colorChoice 「將色彩變更為 colorChoice」,其中 colorChoice 可接受的值為 「紅色」或「綠色」或「藍色」。
注意
若要在片語中使用 Choices 物件做為選擇性元件,請建立 Choices 物件,並將它分別新增至 GrammarBuilder.GrammarBuilder(GrammarBuilder, Int32, Int32) 具有 minRepeat
且 maxRepeat
設定為 0 和 1 的物件。 不論是否說出選擇性元件,都可以辨識包含選擇性元件的片語。
類別 Choices 與語音辨識文法規格 (SRGS) 1.0版所定義的 XML 元素相同 one-of
,且與 命名空間中的 System.Speech.Recognition.SrgsGrammar 類別類似 SrgsOneOf 。
如需定義語音辨識文法的詳細資訊,請參閱 語音辨識。
建構函式
Choices() |
初始化包含空的替代項目集合之 Choices 類別的新執行個體。 |
Choices(GrammarBuilder[]) |
從包含一或多個 Choices 物件的陣列,初始化 GrammarBuilder 類別的新執行個體。 |
Choices(String[]) |
方法
Add(GrammarBuilder[]) |
將陣列(其中包含一或多個GrammarBuilder物件)加入至選項組合。 |
Add(String[]) |
將陣列(其中包含一或多個String物件)加入至選項組合。 |
Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
GetType() |
取得目前執行個體的 Type。 (繼承來源 Object) |
MemberwiseClone() |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
ToGrammarBuilder() |
從這個 GrammarBuilder 物件傳回 Choices 物件。 |
ToString() |
傳回代表目前物件的字串。 (繼承來源 Object) |