Share via


Note

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

GrammarBuilder.AppendDictation Method (String)

Appends grammar logic to provide access to a special-function dictation grammar specified by a string.

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

Syntax

'Declaration
Public Sub AppendDictation ( _
    category As String _
)
'Usage
Dim instance As GrammarBuilder
Dim category As String

instance.AppendDictation(category)
public void AppendDictation(
    string category
)

Parameters

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

Remarks

Special-function dictation grammars are specified within the Microsoft Speech Platform SDK 11 with a special URI syntax of the form grammar:dictation#topic.

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

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

A GrammarBuilder with an appended dictation grammar may also incorporate SemanticResultValue and SemanticResultKey objects.

Examples

The example below creates a Grammar that accepts both free-text dictation, and the spelling of words using individual letters.

The free-text dictation features, triggered by the command "start dictation" and terminated by the command "stop dictation", are built with the GrammarBuilder instance startStop.

The spelling is implemented by appending the special-function spelling grammar to the GrammarBuilder instance spellingGB, using the AppendDictation(String) method. The free-text and spelling features are combined in the GrammarBuilder instance both, which is used to construct the Grammar object.

The 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 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("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(startStop, spellingGB);
    
    Grammar grammar=new Grammar(both);
    grammar.Enabled=true;
    grammar.Name="Free-Text and Spelling Dictation";
    _recognizer.LoadGrammar(grammar);
   
}

See Also

Reference

GrammarBuilder Class

GrammarBuilder Members

AppendDictation Overload

Microsoft.Speech.Recognition Namespace