Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

DictationGrammar Class

Provides access to the system provided grammar used for free text dictation.

Namespace: System.Speech.Recognition
Assembly: System.Speech (in system.speech.dll)

public class DictationGrammar : Grammar
public class DictationGrammar extends Grammar
public class DictationGrammar extends Grammar
Not applicable.

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 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 . For details on specifying grammars, see the discussion on the DictationGrammar(String) 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.

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 DictationGrammar, (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;
}
System.Object
   System.Speech.Recognition.Grammar
    System.Speech.Recognition.DictationGrammar
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.