Share via


GrammarBuilder.AppendDictation Method (String)

Appends grammar logic to provide access special function free text dictation grammars on the basis of a category string.

Namespace: Microsoft.Speech.Recognition
Assembly: Microsoft.Speech (in microsoft.speech.dll)

Syntax

'Declaration
Public Sub AppendDictation ( _
    category As String _
)
public void AppendDictation (
    string category
)
public:
void AppendDictation (
    String^ category
)
public void AppendDictation (
    String category
)
public function AppendDictation (
    category : String
)

Parameters

  • category
    A System.String indicating the type of special function dictation grammar to be appended.

Remarks

Special function dictation grammars are specified within the Speech platform infrastructure with a special URI syntax of the form grammar:dictation#topic.

The category argument supplies value to the #topic file in these URIs.

Currently, only one category is supported: “spelling”.

GrammarBuilder with dictation grammar appended using the AppendDictation(String) method can be freely intermixed without restriction GrammarBuilder instance specifying exact semantics.

Such as GrammarBuilder can be used freely with SemanticResultValue and SemanticResultKey.

Example

The example below creates a Grammar emulating a Dictaphone with spelling support.

The Dictaphone features, triggered by the command "start dictation" and terminated by the command "stop dictation", are built with the dictaphoneGBGrammarBuilder instance, this grammar supports the spelling out of words.

The spelling is implemented by constructing a GrammarBuilder (spellingGB) instance which has the “spelling” dictation appended to it using the AppendDictation(String), and combining it between to GrammarBuilder instances supporting recognition of “start spelling” and “stop spelling” commands.

The s result will be obtainable from the Value property of SemanticValue instance returned with a recognized phrase and accessed with the tag “spellingInput”.

private void DictaphoneSpellingGrammar(){
    
    GrammarBuilder dictaphoneGB = new GrammarBuilder();
    GrammarBuilder dictation = new GrammarBuilder();
    dictation.AppendDictation();
    
    dictaphoneGB.Append(new SemanticResultKey("StartDictation", new SemanticResultValue("Start Dictation",true)));
    dictaphoneGB.Append(new SemanticResultKey("DictationInput", dictation));
    dictaphoneGB.Append(new SemanticResultKey("EndDictation", new SemanticResultValue("Stop Dictation", false)));

    GrammarBuilder spelling = new GrammarBuilder();
    spelling.AppendDictation("spelling");
    GrammarBuilder spellingGB = new GrammarBuilder();
    spellingGB.Append(new SemanticResultKey("StartSpelling", new SemanticResultValue("Start Spelling",true)));
    spellingGB.Append(new SemanticResultKey("spellingInput", spelling));
    spellingGB.Append(new SemanticResultKey("StopSpelling", new SemanticResultValue("Stop Spelling", true)));

    GrammarBuilder both= GrammarBuilder.Add(dictaphoneGB, spellingGB);
    
    Grammar grammar=new Grammar(both);
    grammar.Enabled=true;
    grammar.Name="Dictaphone and Spelling ";
    _recognizer.LoadGrammar(grammar);
   
}

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

GrammarBuilder Class
GrammarBuilder Members
Microsoft.Speech.Recognition Namespace