Choices Classe

Definição

Representa um conjunto de alternativas dentro das restrições de uma gramática de reconhecimento de fala.Represents a set of alternatives in the constraints of a speech recognition grammar.

public ref class Choices
public class Choices
type Choices = class
Public Class Choices
Herança
Choices

Exemplos

O exemplo a seguir cria uma gramática de reconhecimento de fala para a frase "definir plano de fundo como colorChoice", em que colorChoice pode ser uma das cores definidas.The following example creates a speech recognition grammar for the phrase, "Set background to colorChoice", where colorChoice can be one of the defined colors. O GrammarBuilder é usado para definir as restrições para a gramática.The GrammarBuilder is used to define the constraints for the grammar.

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;  
}  

Comentários

Um Choices objeto representa um componente de uma frase que pode ter um dos vários valores.A Choices object represents a component of a phrase that can have one of several values. Use essa classe ao criar uma gramática de reconhecimento de fala a partir de um GrammarBuilder objeto.Use this class when creating a speech recognition grammar from a GrammarBuilder object.

Por exemplo, um Choices objeto poderia representar o componente colorChoice na frase "alterar a cor para colorChoice", onde os valores aceitáveis para colorChoice são "vermelho" ou "verde" ou "azul".For example, a Choices object could represent the component colorChoice in the phrase, "Change the color to colorChoice", where acceptable values for colorChoice are "red", or "green", or "blue".

Observação

Para usar um Choices objeto como um componente opcional em uma frase, crie o Choices objeto e adicione-o a um GrammarBuilder.GrammarBuilder(GrammarBuilder, Int32, Int32) objeto com minRepeat e maxRepeat defina como 0 e 1, respectivamente.To use a Choices object as an optional component in a phrase, create the Choices object and add it to a GrammarBuilder.GrammarBuilder(GrammarBuilder, Int32, Int32) object with minRepeat and maxRepeat set to 0 and 1, respectively. Frases contendo componentes opcionais podem ser reconhecidas se o componente opcional é ou não falado.Phrases containing optional components can be recognized whether or not the optional component is spoken.

A Choices classe serve a mesma função que o one-of elemento XML definido pela versão da gramática do reconhecimento de fala (SRGS) 1,0 e é semelhante à SrgsOneOf classe no System.Speech.Recognition.SrgsGrammar namespace.The Choices class serves the same function as the one-of XML element defined by the Speech Recognition Grammar Specification (SRGS) Version 1.0 and is similar to the SrgsOneOf class in the System.Speech.Recognition.SrgsGrammar namespace.

Para obter mais informações sobre como definir uma gramática de reconhecimento de fala, consulte reconhecimento de fala.For more information about defining a speech recognition grammar, see Speech Recognition.

Construtores

Choices()

Inicializa uma nova instância da classe Choices que contém um conjunto vazio de alternativas.Initializes a new instance of the Choices class that contains an empty set of alternatives.

Choices(GrammarBuilder[])

Inicializa uma nova instância da Choices classe de uma matriz que contém um ou mais objetos GrammarBuilder.Initializes a new instance of the Choices class from an array containing one or more GrammarBuilder objects.

Choices(String[])

Inicializa uma nova instância da Choices classe de uma matriz que contém um ou mais objetos String.Initializes a new instance of the Choices class from an array containing one or more String objects.

Métodos

Add(GrammarBuilder[])

Adiciona uma matriz que contém um ou mais objetos GrammarBuilder ao conjunto de alternativas.Adds an array containing one or more GrammarBuilder objects to the set of alternatives.

Add(String[])

Adiciona uma matriz que contém um ou mais objetos String ao conjunto de alternativas.Adds an array containing one or more String objects to the set of alternatives.

Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
ToGrammarBuilder()

Retorna um objeto GrammarBuilder deste objeto Choices.Returns a GrammarBuilder object from this Choices object.

ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Aplica-se a

Confira também