Grammar.Name 属性

定义

获取或设置 Grammar 对象的名称。

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

属性值

String

Name 属性返回 Grammar 对象的名称。 默认值为 null

示例

以下示例创建两 Grammar 个对象,一个用于数字,一个用于分数。 语法对象分配名称和相对权重和优先级,并由进程内语音识别器加载。 此处未显示该方法CreateDigitsGrammar``CreateFractionsGrammarrecognizer_SpeechRecognized方法。

// 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);  

适用于

另请参阅