How Tos

Last reviewed: 7/15/2011

Article ID: H071116

HOW: Managing dictation shortcuts

The information in this article applies to:

  • LexiconKit 4

Summary

LexiconKit 4 provides a way to enumerate, add, and remove SAPI 5 dictation shortcuts.

More Information

LexiconKit 4 introduces a new resource type CSRLexiconShortcut that represents a SAPI dictation shortcut. You enumerate the CSRLexiconShortcut to determine what shortcuts are defined for the default user.

The following example illustrates enumerating shortcuts.

int numberOfShortcuts = NChantLM1.GetResourceCount(ChantSpeechResource.CSRLexiconShortcut);
for (i = 0; i < numberOfShortcuts; i++)
{
NChantLexiconShortcut nChantLexiconShortcut = NChantLM1.GetChantLexiconShortcut(i);
// Access shortcut properties
String stringVal = nChantLexiconShortcut.Spoken;
}

You add a shortcut with the ChantLM AddShortcut method.

The following example illustrates adding a shortcut directly to a local speech engine lexicon.

// Add shortcut directly to speech engine lexicon
NChantLM1.AddShortcut(ChantSpeechResource.CSRLexiconShortcut, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "work phone", "310-555-1212", 3);

You remove a shortcut with the ChantLM DeleteShortcut method. To edit a shortcut, simply remove it first, then add it.

The following example illustrates deleting a shortcut.

// Delete shortcut directly from speech engine lexicon
NChantLM1.DeleteShortcut(ChantSpeechResource.CSRLexiconShortcut, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "work phone", "310-555-1212", 3);