共用方式為


GrammarBuilder.Culture Property

Definition

Gets or sets the culture of the speech recognition grammar.

public:
 property System::Globalization::CultureInfo ^ Culture { System::Globalization::CultureInfo ^ get(); void set(System::Globalization::CultureInfo ^ value); };
public System.Globalization.CultureInfo Culture { get; set; }
member this.Culture : System.Globalization.CultureInfo with get, set
Public Property Culture As CultureInfo

Property Value

The culture of the GrammarBuilder. The default is the executing thread's CurrentUICulture property.

Examples

The following example creates a speech recognition grammar for ordering a pizza with up to four toppings. It specifically sets the GrammarBuilder object's culture to English (United States).

private static Grammar CreatePizzaGrammar()
{

  // Create a Choices object with alternatives for toppings.
  Choices toppings = new Choices(new string[] {
    "cheese", "mushroom", "tomato", "onion",
    "anchovy", "chicken", "pepperoni"});

  // Create a GrammarBuilder and append the Choices object.
  GrammarBuilder andToppings = new GrammarBuilder("and", 0, 1);
  andToppings.Append(toppings);

  // Construct the phrase.
  GrammarBuilder gb = new GrammarBuilder("I would like a", 0, 1);
  gb.Append(toppings);
  gb.Append(new GrammarBuilder(andToppings, 0, 3));
  gb.Append("pizza");

  // Create the Grammar from the GrammarBuilder.
  Grammar grammar = new Grammar(gb);
  grammar.Name = "Pizza Order";

  return grammar;
}

Remarks

The Grammar constructor creates a Grammar object that can be used by a speech recognizer of the corresponding culture. Only the Culture property of the GrammarBuilder that is provided as the parameter to the Grammar constructor is used to set the culture of the resulting speech recognition grammar.

Microsoft Windows and the System.Speech API accept all valid language-country codes. To perform speech recognition using the language specified in the Culture property, a speech recognition engine that supports that language-country code must be installed. The speech recognition engines that shipped with Microsoft Windows 7 work with the following language-country codes.

  • en-GB. English (United Kingdom)

  • en-US. English (United States)

  • de-DE. German (Germany)

  • es-ES. Spanish (Spain)

  • fr-FR. French (France)

  • ja-JP. Japanese (Japan)

  • zh-CN. Chinese (China)

  • zh-TW. Chinese (Taiwan)

Two-letter language codes such as "en", "fr", or "es" are also permitted.

Applies to

See also