How do I use phrase lists in command vocabularies?
Last reviewed: 9/1/2012
HOW Article ID: H091202
The information in this article applies to:
- SpeechKit 7
Summary
Chant command vocabularies map to Dragon voice menus that support phrases lists that can be set at runtime to expand command choices based on application states.
An application can use lists to dynamically expand command list choices.
More Information
Command vocabularies are defined using the ChantCommandVocab class. The list of phrases choices are defined using the ChantSR DefineResource method.
The following example illustrates using a phrase lists in a command vocabulary:
// Define the vocabulary
NChantCommandVocab nChantCommandVocab = new NChantCommandVocab(NChantSR1, "commands");
// Add commands to the vocabulary
nChantCommandVocab.AddCommand("red <item>");
nChantCommandVocab.AddCommand("blue <item>");
nChantCommandVocab.AddCommand("green <item>");
// Create your list resource (one for each unique list embedded in your commands)
_ListID = NChantSR1.DefineResource(ChantSpeechResource.CSRVocabList, "item", ChantResourceFunction.CRFNone, null, null, 0, nChantCommandVocab.ResourceID);
NChantSR1.AddResource(ChantSpeechResource.CSRVocabPhrase, _ListID, "car");
NChantSR1.AddResource(ChantSpeechResource.CSRVocabPhrase, _ListID, "truck");
NChantSR1.AddResource(ChantSpeechResource.CSRVocabPhrase, _ListID, "boat");
// Enable the vocabulary
nChantCommandVocab.Enable();
// Then enable the list
NChantSR1.EnableResource(ChantSpeechResource.CSRVocabList, _ListID);
// Disable the vocabulary
nChantCommandVocab.Disable();
// You do not have to explicitly disable the list. The vocabulary disable does it automatically.
// Define the vocabulary
CChantCommandVocab* pChantCommandVocab = new CChantCommandVocab(m_pChantSR, L"commands");
// Add commands to the vocabulary
pChantCommandVocab->AddCommand(L"red <item>");
pChantCommandVocab->AddCommand(L"blue <item>");
pChantCommandVocab->AddCommand(L"green <item>");
// Create your list resource (one for each unique list embedded in your commands)
m_ListID = m_pChantSR->DefineResource(CSRVocabList, L"item", CRFNone, NULL, NULL, 0, pChantCommandVocab->GetResourceID());
m_pChantSR->AddResource(CSRVocabPhrase, m_ListID, L"car");
m_pChantSR->AddResource(CSRVocabPhrase, m_ListID, L"truck");
m_pChantSR->AddResource(CSRVocabPhrase, m_ListID, L"boat");
// Enable the vocabulary
pChantCommandVocab->Enable();
// Then enable the list
m_pChantSR->EnableResource(CSRVocabList, m_ListID);
// Disable the vocabulary
pChantCommandVocab->Disable();
// You do not have to explicitly disable the list. The vocabulary disable does it automatically.
// Define the vocabulary
CChantCommandVocab* pChantCommandVocab = new CChantCommandVocab(ChantSR1, "commands");
// Add commands to the vocabulary
pChantCommandVocab->AddCommand("red <item>");
pChantCommandVocab->AddCommand("blue <item>");
pChantCommandVocab->AddCommand("green <item>");
// Create your list resource (one for each unique list embedded in your commands)
m_ListID = NChantSR1.DefineResource(CSRVocabList, "item", CRFNone, NULL, NULL, 0, pChantCommandVocab->GetResourceID());
ChantSR1->AddResource(CSRVocabPhrase, m_ListID, "car");
ChantSR1->AddResource(CSRVocabPhrase, m_ListID, "truck");
ChantSR1->AddResource(CSRVocabPhrase, m_ListID, "boat");
// Enable the vocabulary
pChantCommandVocab->Enable();
// Then enable the list
ChantSR1->EnableResource(CSRVocabList, m_ListID);
// Disable the vocabulary
pChantCommandVocab->Disable();
// You do not have to explicitly disable the list. The vocabulary disable does it automatically.
var aTChantCommandVocab: TChantCommandVocab;
// Define the vocabulary
aTChantCommandVocab := TChantCommandVocab.Create(ChantSR1, 'commands');
// Add commands to the vocabulary
aTChantCommandVocab.AddCommand('red <item>');
aTChantCommandVocab.AddCommand('blue <item>');
aTChantCommandVocab.AddCommand('green <item>');
// Create your list resource (one for each unique list embedded in your commands)
_ListID = ChantSR1.DefineResource(ChantSpeechResource.CSRVocabList, 'item', CRFNone, nil, nil, 0, aTChantCommandVocab.ResourceID);
ChantSR1.AddResource(CSRVocabPhrase, _ListID, 'car');
ChantSR1.AddResource(CSRVocabPhrase, _ListID, 'truck');
ChantSR1.AddResource(CSRVocabPhrase, _ListID, 'boat');
// Enable the vocabulary
aTChantCommandVocab.Enable();
// Then enable the list
ChantSR1.EnableResource(CSRVocabList, _ListID);
// Disable the vocabulary
aTChantCommandVocab.Disable();
// You do not have to explicitly disable the list. The vocabulary disable does it automatically.
// Define the vocabulary
JChantCommandVocab jChantCommandVocab = new JChantCommandVocab(JChantSR1, "commands");
// Add commands to the vocabulary
jChantCommandVocab.addCommand("red <item>");
jChantCommandVocab.addCommand("blue <item>");
jChantCommandVocab.addCommand("green <item>");
// Create your list resource (one for each unique list embedded in your commands)
_ListID = JChantSR1.defineResource(ChantSpeechResource.CSRVocabList, "item", ChantResourceFunction.CRFNone, null, null, 0, jChantCommandVocab.getResourceID());
JChantSR1.addResource(ChantSpeechResource.CSRVocabPhrase, _ListID, "car");
JChantSR1.addResource(ChantSpeechResource.CSRVocabPhrase, _ListID, "truck");
JChantSR1.addResource(ChantSpeechResource.CSRVocabPhrase, _ListID, "boat");
// Enable the vocabulary
jChantCommandVocab.enable();
// Then enable the list
JChantSR1.enableResource(ChantSpeechResource.CSRVocabList, _ListID);
// Disable the vocabulary
jChantCommandVocab.disable();
// You do not have to explicitly disable the list. The vocabulary disable does it automatically.
// Define a command vocabulary
var CommandVocabID = WChantSR1.DefineResource(CSRCommandVocab, "commands");
// Add commands to the vocabulary
WChantSR1.AddResource(CSRVocabPhrase,CommandVocabID,"red <item>");
WChantSR1.AddResource(CSRVocabPhrase,CommandVocabID,"blue <item>");
WChantSR1.AddResource(CSRVocabPhrase,CommandVocabID,"green <item>");
// Create your list resource (one for each unique list embedded in your commands)
_ListID = WChantSR1.DefineResource(ChantSpeechResource.CSRVocabList, "item", CRFNone, 0, 0, 0, CommandVocabID);
WChantSR1.AddResource(CSRVocabPhrase, _ListID, "car");
WChantSR1.AddResource(CSRVocabPhrase, _ListID, "truck");
WChantSR1.AddResource(CSRVocabPhrase, _ListID, "boat");
// Enable command vocabulary
WChantSR1.EnableResource(CSRCommandVocab, CommandVocabID);
// Then enable the list
WChantSR1.EnableResource(CSRVocabList, _ListID);
// Disable the vocabulary
WChantSR1.DisableResource(CSRCommandVocab, CommandVocabID);
// You do not have to explicitly disable the list. The vocabulary disable does it automatically.
Dim CommandVocabID As Integer
' Define a command vocabulary
CommandVocabID = XChantSR1.DefineResource(CSRCommandVocab, "commands")
' Add commands to the vocabulary
XChantSR1.AddResource CSRVocabPhrase, CommandVocabID, "red <item>"
XChantSR1.AddResource CSRVocabPhrase, CommandVocabID, "blue <item>"
XChantSR1.AddResource CSRVocabPhrase, CommandVocabID, "green <item>"
// Create your list resource (one for each unique list embedded in your commands)
_ListID = NChantSR1.DefineResource(CSRVocabList, "item", CRFNone, Nothing, Nothing, 0, CommandVocabID)
XChantSR1.AddResource CSRVocabPhrase, _ListID, "car"
XChantSR1.AddResource CSRVocabPhrase, _ListID, "truck"
XChantSR1.AddResource CSRVocabPhrase, _ListID, "boat"
' Enable command vocabulary
XChantSR1.EnableResource CSRCommandVocab, CommandVocabID
// Then enable the list
XChantSR1.EnableResource CSRVocabList, _ListID
' Disable command vocabulary
XChantSR1.DisableResource ChantSpeechResource.CSRCommandVocab, CommandVocabID
// You do not have to explicitly disable the list. The vocabulary disable does it automatically.
' Define the vocabulary
Dim nChantCommandVocab As NChantCommandVocab
nChantCommandVocab = New NChantCommandVocab(NChantSR1, "commands")
' Add commands to the vocabulary
nChantCommandVocab.AddCommand("red <item>");
nChantCommandVocab.AddCommand("blue <item>");
nChantCommandVocab.AddCommand("green <item>");
' Create your list resource (one for each unique list embedded in your commands)
_ListID = NChantSR1.DefineResource(ChantSpeechResource.CSRVocabList, "item", ChantResourceFunction.CRFNone, null, null, 0, nChantCommandVocab.ResourceID);
NChantSR1.AddResource(ChantSpeechResource.CSRVocabPhrase, _ListID, "car");
NChantSR1.AddResource(ChantSpeechResource.CSRVocabPhrase, _ListID, "truck");
NChantSR1.AddResource(ChantSpeechResource.CSRVocabPhrase, _ListID, "boat");
' Enable the vocabulary
nChantCommandVocab.Enable();
' Then enable the list
NChantSR1.EnableResource(ChantSpeechResource.CSRVocabList, _ListID);
' Enable the vocabulary
nChantCommandVocab.Enable()
' Disable the vocabulary
nChantCommandVocab.Disable()
' You do not have to explicitly disable the list. The vocabulary disable does it automatically.
For additional help with command vocabularies, contact Chant Support via or web.