Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

GrammarBuilder.AppendDictation Method

Appends grammar logic to provide access the default, free-text, dictation grammar provided by the Microsoft Speech Platform SDK 11.

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

Syntax

'Declaration
Public Sub AppendDictation
'Usage
Dim instance As GrammarBuilder

instance.AppendDictation()
public void AppendDictation()

Remarks

A GrammarBuilder object that appends a dictation grammar using the AppendDictation() method can be combined with a GrammarBuilder that specifies SemanticResultValue and SemanticResultKey objects.

Examples

The following example creates a Grammar that accepts free-speech dictation. The grammar is constructed from two GrammarBuilder instances; one supports the commands “start dictation” and “stop dictation”, the other appends a free-text dictation grammar using the AppendDictation method. The dictation result will be obtainable from the Value property of SemanticValue instance returned with a recognized phrase and accessed with the tag “DictationInput”.

private void freeTextDictation(){
    GrammarBuilder startStop = new GrammarBuilder();
    GrammarBuilder dictation = new GrammarBuilder();
    dictation.AppendDictation();
    
    startStop.Append(new SemanticResultKey("StartDictation", new SemanticResultValue("Start Dictation",true)));
    startStop.Append(new SemanticResultKey("DictationInput", dictation));
    startStop.Append(new SemanticResultKey("StopDictation", new SemanticResultValue("Stop Dictation", false)));
    Grammar grammar=new Grammar(startStop);
    grammar.Enabled=true;
    grammar.Name=" Free-Text Dictation ";
    _recognizer.LoadGrammar(grammar);
   
}

See Also

Reference

GrammarBuilder Class

GrammarBuilder Members

AppendDictation Overload

Microsoft.Speech.Recognition Namespace