Grammar.Name 属性
定义
public:
property System::String ^ Name { System::String ^ get(); void set(System::String ^ value); };
public string Name { get; set; }
member this.Name : string with get, set
Public Property Name As String
属性值
Name 属性返回 Grammar 对象的名称。The Name property returns the name of the Grammar object. 默认值为 null。The default is null.
示例
下面的示例创建两个 Grammar 对象,一个用于数字,一个用于分数。The following example creates two Grammar objects, one for digits and one for fractions. 为语法对象分配名称、相对权重和优先级,并由进程内语音识别器加载。The Grammar objects are assigned names and relative weights and priorities, and loaded by an in-process speech recognizer. CreateDigitsGrammar CreateFractionsGrammar recognizer_SpeechRecognized 此处未显示、和方法。The CreateDigitsGrammar, CreateFractionsGrammar, and recognizer_SpeechRecognized methods are not shown here.
// Create a Grammar for recognizing numeric digits.
Grammar digitsGrammar = CreateDigitsGrammar();
digitsGrammar.Name = "Digits Grammar";
digitsGrammar.Priority = 2;
digitsGrammar.Weight = 0.6f;
// Create a Grammar for recognizing fractions.
Grammar fractionsGrammar = CreateFractionsGrammar();
fractionsGrammar.Name = "Fractions Grammar";
fractionsGrammar.Priority = 1;
fractionsGrammar.Weight = 1f;
// Create an in-process speech recognizer.
SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
recognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(
recognizer_SpeechRecognized);
// Load the digits and fractions Grammar objects.
recognizer.LoadGrammar(digitsGrammar);
recognizer.LoadGrammar(fractionsGrammar);
// Start recognition.
recognizer.SetInputToDefaultAudioDevice();
recognizer.RecognizeAsync(RecognizeMode.Multiple);