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