DictationGrammar DictationGrammar DictationGrammar DictationGrammar Class


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


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. The 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();  

  // 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. This class supports both default and custom DictationGrammar objects. For information about selecting a dictation grammar, see the DictationGrammar(String) constructor.

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. To add context to the dictation grammar, use the SetDictationContext method.


DictationGrammar objects do not support the Priority property. DictationGrammar throws a NotSupportedException if Priority is set.


DictationGrammar() DictationGrammar() DictationGrammar() DictationGrammar()

Initializes a new instance of the DictationGrammar class for the default dictation grammar provided by Windows Desktop Speech Technology.

DictationGrammar(String) DictationGrammar(String) DictationGrammar(String) DictationGrammar(String)

Initializes a new instance of the DictationGrammar class with a specific dictation grammar.


Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SetDictationContext(String, String) SetDictationContext(String, String) SetDictationContext(String, String) SetDictationContext(String, String)

Adds a context to a dictation grammar that has been loaded by a SpeechRecognizer or a SpeechRecognitionEngine object.

StgInit(Object[]) StgInit(Object[]) StgInit(Object[]) StgInit(Object[])

The StgInit method initializes a strongly-typed grammar.

(Inherited from Grammar)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)


Enabled Enabled Enabled Enabled

Gets or sets a value that controls whether a Grammar can be used by a speech recognizer to perform recognition.

(Inherited from Grammar)
IsStg IsStg IsStg IsStg

Gets whether a grammar is strongly typed.

(Inherited from Grammar)
Loaded Loaded Loaded Loaded

Gets whether a Grammar has been loaded by a speech recognizer.

(Inherited from Grammar)
Name Name Name Name

Gets or sets the name of a Grammar object.

(Inherited from Grammar)
Priority Priority Priority Priority

Gets or sets the priority value of a Grammar object.

(Inherited from Grammar)
ResourceName ResourceName ResourceName ResourceName

Gets or sets a value with the name of a binary resource that was used to load the current Grammar.

(Inherited from Grammar)
RuleName RuleName RuleName RuleName

Gets the name of the root rule or entry point of a Grammar object.

(Inherited from Grammar)
Weight Weight Weight Weight

Gets or sets the weight value of a Grammar object.

(Inherited from Grammar)


SpeechRecognized SpeechRecognized SpeechRecognized SpeechRecognized

Raised when a speech recognizer performs recognition using the Grammar object.

(Inherited from Grammar)

Applies to

See also