DictationGrammar.SetDictationContext Method

Allows an application define a context to be used with a dictation model.

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

public void SetDictationContext (
	string precedingText,
	string subsequentText
)
public void SetDictationContext (
	String precedingText, 
	String subsequentText
)
public function SetDictationContext (
	precedingText : String, 
	subsequentText : String
)
Not applicable.

Parameters

precedingText

A string containing a text used to mark the beginning of a context used in speech recognition.

subsequentText

A string containing a text used to mark the end of a context used in speech recognition.

By default, the DictationGrammar language model does not make use of specific words or word order to identify and interpret audio input.

By defining a dictation context, an application indicates to a recognition engine that input marked off by precedingText and/or subsequentText are of particular value and can be assumed to be linguistically connected with the dictation context markers.

The precedingText and subsequentText can be set to a null reference (Nothing in Visual Basic).

  • If both precedingText and subsequentText values are non a null reference (Nothing in Visual Basic), then a recognition engine uses the terms to bracket possible candidate phrases.

  • If the precedingText value is non a null reference (Nothing in Visual Basic), but the subsequentText value is a null reference (Nothing in Visual Basic), a recognition engine attempts to construct and identify phrases beginning with the precedingText.

  • If the subsequentText value is non a null reference (Nothing in Visual Basic), but the precedingText value is a null reference (Nothing in Visual Basic), a recognition engine attempts to construct and identify phrases ending with the subsequentText.

  • Setting both precedingText and subsequentText values are a null reference (Nothing in Visual Basic), is equivalent to removing any dictation context.

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;
}

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

Community Additions

ADD
Show: