DictationGrammar 類別

定義

表示語音辨識文法,用來進行自由文字聽寫。Represents a speech recognition grammar used for free text dictation.

public ref class DictationGrammar : System::Speech::Recognition::Grammar
public class DictationGrammar : System.Speech.Recognition.Grammar
type DictationGrammar = class
    inherit Grammar
Public Class DictationGrammar
Inherits Grammar
繼承
DictationGrammar

範例

下列範例會建立三個聽寫文法、將其新增至SpeechRecognitionEngine新的物件, 並傳回新的物件。The following example creates three dictation grammars, adds them to a new SpeechRecognitionEngine object, and returns the new object. 第一個文法是預設的聽寫文法。The first grammar is the default dictation grammar. 第二個文法是拼寫聽寫文法。The second grammar is the spelling dictation grammar. 第三個文法是預設的聽寫文法, 其中包含內容片語。The third grammar is the default dictation grammar that includes a context phrase. 方法是用來在內容片語載入SpeechRecognitionEngine至物件之後, 將其與聽寫文法產生關聯。 SetDictationContextThe SetDictationContext method is used to associate the context phrase with the dictation grammar after it is loaded to the SpeechRecognitionEngine object.

  
private SpeechRecognitionEngine LoadDictationGrammars()  
{  
  
  // Create a default dictation grammar.  
  DictationGrammar defaultDictationGrammar = new DictationGrammar();  
  defaultDictationGrammar.Name = "default dictation";  
  defaultDictationGrammar.Enabled = true;  
  
  // Create the spelling dictation grammar.  
  DictationGrammar spellingDictationGrammar =  
    new DictationGrammar("grammar:dictation#spelling");  
  spellingDictationGrammar.Name = "spelling dictation";  
  spellingDictationGrammar.Enabled = true;  
  
  // Create the question dictation grammar.  
  DictationGrammar customDictationGrammar =  
    new DictationGrammar("grammar:dictation");  
  customDictationGrammar.Name = "question dictation";  
  customDictationGrammar.Enabled = true;  
  
  // Create a SpeechRecognitionEngine object and add the grammars to it.  
  SpeechRecognitionEngine recoEngine = new SpeechRecognitionEngine();  
  recoEngine.LoadGrammar(defaultDictationGrammar);  
  recoEngine.LoadGrammar(spellingDictationGrammar);  
  recoEngine.LoadGrammar(customDictationGrammar);  
  
  // Add a context to customDictationGrammar.  
  customDictationGrammar.SetDictationContext("How do you", null);  
  
  return recoEngine;  
}  
  

備註

這個類別會為應用程式提供預先定義的語言模型, 可將語音的使用者輸入處理成文字。This class provides applications with a predefined language model that can process spoken user input into text. 這個類別支援預設和自訂DictationGrammar物件。This class supports both default and custom DictationGrammar objects. 如需選取聽寫文法的詳細資訊, 請DictationGrammar(String)參閱函式。For information about selecting a dictation grammar, see the DictationGrammar(String) constructor.

根據預設, 語言DictationGrammar模型是免費的內容。By default, the DictationGrammar language model is context free. 它不會使用特定單字或單字順序來識別和解讀音訊輸入。It does not make use of specific words or word order to identify and interpret audio input. 若要將內容新增至聽寫文法, 請SetDictationContext使用方法。To add context to the dictation grammar, use the SetDictationContext method.

注意

DictationGrammar物件不支援Priority屬性。DictationGrammar objects do not support the Priority property. DictationGrammarNotSupportedException 如果Priority已設定, 則擲回。DictationGrammar throws a NotSupportedException if Priority is set.

建構函式

DictationGrammar()

針對 Windows 桌面語音技術所提供的預設聽寫文法,初始化 DictationGrammar 類別的新執行個體。Initializes a new instance of the DictationGrammar class for the default dictation grammar provided by Windows Desktop Speech Technology.

DictationGrammar(String)

使用特定的聽寫文法,初始化 DictationGrammar 類別的新執行個體。Initializes a new instance of the DictationGrammar class with a specific dictation grammar.

屬性

Enabled

取得或設定值,這個值控制語音辨識器是否可以使用 Grammar 來執行辨識。Gets or sets a value that controls whether a Grammar can be used by a speech recognizer to perform recognition.

(繼承來源 Grammar)
IsStg

取得文法是否為強型別。Gets whether a grammar is strongly typed.

(繼承來源 Grammar)
Loaded

取得語音辨識器是否已經載入 GrammarGets whether a Grammar has been loaded by a speech recognizer.

(繼承來源 Grammar)
Name

取得或設定 Grammar 物件的名稱。Gets or sets the name of a Grammar object.

(繼承來源 Grammar)
Priority

取得或設定 Grammar 物件的優先權值。Gets or sets the priority value of a Grammar object.

(繼承來源 Grammar)
ResourceName

取得或設定值,這個值包含已用來載入目前 Grammar 的二進位資源的名稱。Gets or sets a value with the name of a binary resource that was used to load the current Grammar.

(繼承來源 Grammar)
RuleName

取得 Grammar 物件的根規則或進入點名稱。Gets the name of the root rule or entry point of a Grammar object.

(繼承來源 Grammar)
Weight

取得或設定 Grammar 物件的加權值。Gets or sets the weight value of a Grammar object.

(繼承來源 Grammar)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
SetDictationContext(String, String)

將內容加入至聽寫文法(已由SpeechRecognizerSpeechRecognitionEngine物件載入)。Adds a context to a dictation grammar that has been loaded by a SpeechRecognizer or a SpeechRecognitionEngine object.

StgInit(Object[])

StgInit 方法會初始化強型別文法。The StgInit method initializes a strongly-typed grammar.

(繼承來源 Grammar)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

事件

SpeechRecognized

當語音辨識器使用 Grammar 物件執行辨識時引發。Raised when a speech recognizer performs recognition using the Grammar object.

(繼承來源 Grammar)

適用於

另請參閱