.NET Framework Class Library
DictationGrammar Class

Represents a grammar used for free text dictation.

Namespace:  System.Speech.Recognition
Assembly:  System.Speech (in System.Speech.dll)
Syntax

Visual Basic (Declaration)
Public Class DictationGrammar _
    Inherits Grammar
Visual Basic (Usage)
Dim instance As DictationGrammar
C#
public class DictationGrammar : Grammar
Visual C++
public ref class DictationGrammar : public Grammar
JScript
public class DictationGrammar extends Grammar
Remarks

The DictationGrammar inherits from Grammar.

NoteNote:

Despite inheriting from Grammar, DictationGrammar objects do not support Priority.

The DictationGrammar provides applications with a predefined language models that can process spoken user input into text, including punctuation and spelling.

The Speech platform is extensible and developers can either obtain instances of the default DictationGrammar object (obtained through the default constructor DictationGrammar()()()), or specify a type of DictationGrammar with extensions or special features by using the DictationGrammar(String) constructor.

Specification of grammars is indicated through a special URI (Universal Resource Identifier) understood by the infrastructure of the Speech platform. For details on specifying grammars, see the discussion on the DictationGrammar(String) constructor topic.

By default, and unlike most Grammar based objects, the DictationGrammar language model is context free: that it does not make use of specific words or word order to identify and interpret audio input.

However, an application can modify the DictationGrammar programming to increase the robustness of desktop dictation by using SetDictationContext.

Examples

In the example below, the following DictationGrammar instances are created and loaded:

  • A default DictationGrammar instance (defaultDictationGrammar) created using the default constructor DictationGrammar()()().

  • A DictationGrammar instance (spellingDictationGrammar) supporting spelling is specified by the argument to DictationGrammar(String)

  • A default DictationGrammar instance, is specified by the argument to [M:System.Speech.Recognition.DictationGrammar.#ctor(System.Strin], (helpcontextDictationGrammar) is created and configured with a context to support help queries by watching for the phrase "How do you"

private void LoadDictationGrammars() {

    //Default Dictation Grammar
    DictationGrammar defaultDictationGrammar = new DictationGrammar();
                defaultDictationGrammar.Name = "Default Dictation";
    defaultDictationGrammar.Enabled = true;
    AddGrammar(defaultDictationGrammar, null, true);            

    //Spelling Dictation Grammar
    DictationGrammar spellingDictationGrammar = new DictationGrammar("grammar:dictation#Spelling");
    spellingDictationGrammar.Name = "Spelling Dictation";
    spellingDictationGrammar.Enabled = true;          
    AddGrammar(spellingDictationGrammar, null, true);

    //context Dictation Grammar
    DictationGrammar helpcontextDictationGrammar = new DictationGrammar("grammar:dictation");
    helpcontextDictationGrammar.Name = "Contextual Dictation Grammar";
    helpcontextDictationGrammar.Enabled = true;
    //_recognizer.Enabled = true;
    AddGrammar(helpcontextDictationGrammar, null, false); 
    //Do this synchronously so we can safely set the context
    //This is define a good context start for help question, e.g. How do you, uh, um you know.... ;->
    helpcontextDictationGrammar.SetDictationContext("How do you", null);
    return;
}
Inheritance Hierarchy

System..::.Object
  System.Speech.Recognition..::.Grammar
    System.Speech.Recognition..::.DictationGrammar
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Tags :


Page view tracker