Share via


SPDUI_AddRemoveWord (SAPI 5.3)

Microsoft Speech API 5.3

SPDUI_AddRemoveWord (C/C++)

SpeechAddRemoveWord (Automation)

SPDUI_AddRemoveWord defines the string for displaying UI to modify the lexicon.

It is not a SAPI 5 compliance requirement for a speech recognition engine to implement this UI for SPDUI_AddRemoveWord.

If a speech engine is being written for the desktop or a graphical environment, users can modify the set of words that will be recognized or synthesized (see ISpLexicon).

Using the SDK sample application Dictation Pad, the user can modify the lexicon using the Voice menu-->Add/Delete Words. When the user selects this menu item, Dictation Pad directly accesses the default SR engine's graphical lexicon editor through SPDUI_AddRemoveWord. If the speech recognition (SR) engine does not support the Training UI (see ISpTokenUI::IsUISupported), the menu item will be unavailable.

When to Access

The application could monitor the user's speech experience (correction type and frequency). If the user corrects a recognition by typing a word that is missing from the lexicon (see ISpLexicon), the application could prompt the user to add it to the lexicon using ISpRecognizer::DisplayUI and SPDUI_AddRemoveWord.

  
#define SPDUI_AddRemoveWord        L"AddRemoveWord"

Example

The following code snippet illustrates the use of ISpTokenUI::IsUISupported using SPDUI_AddRemoveWord.

  
// Declare local identifiers:
HRESULT                    hr = S_OK;
CComPtr<ISpObjectToken>    cpObjectToken;
CComPtr<ISpTokenUI>        cpTokenUI;
BOOL                       fSupported;

// Get the default speech recognizer token.
hr = SpGetDefaultTokenFromCategoryId(SPCAT_RECOGNIZERS, &cpObjectToken;);

if (SUCCEEDED(hr))
{
   // Get the object token's UI.
   hr = cpObjectToken->QueryInterface(&cpTokenUI;);
}

if (SUCCEEDED(hr))
{
   // Check if default speech recognizer
   // has UI for editing the lexicon.
   hr = cpTokenUI->IsUISupported(SPDUI_AddRemoveWord, NULL, NULL, NULL, &fSupported;);
}

if (SUCCEEDED(hr))
{
   // If fSupported = TRUE, then default speech
   // recognizer has UI for modifying the lexicon.
}

The following code snippet illustrates the use of ISpRecognizer::DisplayUI using SPDUI_AddRemoveWord.

  
// Declare local identifiers:
HRESULT                    hr = S_OK;
CComPtr<ISpRecognizer>     cpRecognizer;
HWND                       hwndParent;

// Display lexicon editing UI for the current recognizer.
hr = cpRecognizer->DisplayUI(hwndParent, L"Microphone Training", SPDUI_AddRemoveWord, NULL, NULL);

if (SUCCEEDED(hr))
{
   // Do stuff here.
}