How do I edit dictation shortcuts?
Last reviewed: 7/15/2011
HOW Article ID: H071116
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;
}
int numberOfShortcuts = pCChantLM->GetResourceCount(CSRLexiconShortcut);
for (i = 0; i < numberOfShortcuts; i++)
{
CChantLexiconShortcut* pChantLexiconShortcut = pChantLM->GetChantLexiconShortcut(i);
// Access shortcut properties
wchar_t* pszVal = pChantLexiconShortcut->GetSpoken();
}
int numberOfShortcuts = pCChantLM->GetResourceCount(CSRLexiconShortcut);
for (i = 0; i < numberOfShortcuts; i++)
{
CChantLexiconShortcut* pChantLexiconShortcut = pChantLM->GetChantLexiconShortcut(i);
// Access shortcut properties
String stringVal = pChantLexiconShortcut->GetSpoken();
}
var
aTChantLexiconShortcut: TChantLexiconShortcut;
numberOfShortcuts: Integer;
i: Integer;
stringVal: string;
begin
numberOfShortcuts := ChantLM1.GetResourceCount(CSRLexiconShortcut);
for i := 0 to numberOfShortcuts - 1 do
begin
aTChantLexiconShortcut := ChantLM1.GetChantLexiconShortcut(nIndex);
// Access shortcut properties
stringVal := aTChantLexiconShortcut.Spoken;
end;
end;
int numberOfShortcuts = JChantLM1.getResourceCount(ChantSpeechResource.CSRLexiconShortcut);
for (i = 0; i < numberOfShortcuts; i++)
{
JChantLexiconShortcut jChantLexiconShortcut = JChantLM1.getChantLexiconShortcut(i);
// Access shortcut properties
String stringVal = jChantLexiconShortcut.getSpoken();
}
numberOfShortcuts = WChantLM1.GetResourceCount(CSRLexiconShortcut);
for (i = 0; i < numberOfShortcuts; i++)
{
var wChantLexiconShortcut = WChantLM1.GetResource(CSRLexiconShortcut, i);
// Access shortcut properties
var stringVal = wChantLexiconShortcut.Spoken
}
Dim aXChantLexiconShortcut As XChantLexiconShortcut
Dim I as Integer
Dim numberOfShortcuts As Integer
Dim stringVal As String
numberOfShortcuts = XChantLM1.GetResourceCount(CSRLexiconShortcut);
For I = 0 To numberOfShortcuts - 1
Set aXChantLexiconShortcut = XChantLM1.GetResource(CSRLexiconShortcut, I)
' Access shortcut properties
stringVal = aXChantLexiconShortcut.Spoken
Next I
Dim nChantLexiconShortcut As NChantLexiconShortcut
Dim I as Integer
Dim numberOfShortcuts as Integer
Dim stringVal As String
numberOfShortcuts = NChantLM1.GetResourceCount(ChantSpeechResource.CSRLexiconShortcut)
For I = 0 To numberOfShortcuts - 1
nChantLexiconShortcut = NChantLM1.GetChantLexiconShortcut(i)
' Access shortcut properties
stringVal = nChantLexiconShortcut.Spoken
Next I
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);
// Add shortcut directly to speech engine lexicon
pChantLM->AddShortcut(CSRLexiconShortcut, L"Microsoft Speech Recognizer 8.0 for Windows (English - US)", L"work phone", L"310-555-1212", 3);
// Add shortcut directly to speech engine lexicon
pChantLM->AddShortcut(CSRLexiconShortcut, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "work phone", "310-555-1212", 3);
// Add shortcut directly to speech engine lexicon
ChantLM1.AddShortcut(CSRLexiconShortcut, 'Microsoft Speech Recognizer 8.0 for Windows (English - US)', 'work phone', '310-555-1212', 3);
// Add shortcut directly to speech engine lexicon
JChantLM1.addShortcut(ChantSpeechResource.CSRLexiconShortcut, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "work phone", "310-555-1212", 3);
// Add shortcut directly to speech engine lexicon
WChantLM1.AddShortcut(CSRLexiconShortcut, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "work phone", "310-555-1212", 3);
' Add shortcut directly to speech engine lexicon
XChantLM1.AddShortcut CSRLexiconShortcut, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "work phone", "310-555-1212", 3
' 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);
// Delete shortcut directly from speech engine lexicon
pChantLM->DeleteShortcut(CSRLexiconShortcut, L"Microsoft Speech Recognizer 8.0 for Windows (English - US)", L"work phone", L"310-555-1212", 3);
// Delete shortcut directly from speech engine lexicon
pChantLM->DeleteShortcut(CSRLexiconShortcut, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "work phone", "310-555-1212", 3);
// Delete shortcut directly from speech engine lexicon
ChantLM1.DeleteShortcut(CSRLexiconShortcut, 'Microsoft Speech Recognizer 8.0 for Windows (English - US)', 'work phone', '310-555-1212', 3);
// Delete shortcut directly from speech engine lexicon
JChantLM1.deleteShortcut(ChantSpeechResource.CSRLexiconShortcut, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "work phone", "310-555-1212", 3);
// Delete shortcut directly from speech engine lexicon
WChantLM1.DeleteShortcut(CSRLexiconShortcut, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "work phone", "310-555-1212", 3);
' Delete shortcut directly from speech engine lexicon
XChantLM1.DeleteShortcut CSRLexiconShortcut, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "work phone", "310-555-1212", 3
' 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)