ISpRecoGrammar::IsPronounceable (Microsoft Speech Platform)

Microsoft Speech Platform SDK 11

Microsoft Speech Platform

ISpRecoGrammar::IsPronounceable

ISpRecoGrammar::IsPronounceable calls the SR engine object to determine if the word has a pronunciation.

HRESULT IsPronounceable(
   LPCWSTR                *pszWord,
   SPWORDPRONOUNCEABLE    *pfPronounceable
);

Parameters

pszWord
[in, string] The word to test. Length must be equal to or less than SP_MAX_WORD_LENGTH.
pfPronounceable
[out] Flag, from among the following list, indicating the if the word is pronounceable by the SR engine. See Remarks section.
Value Description
SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE The word is not pronounceable by the SR engine, and is not located in the lexicon and/or the engine's dictionary.
SPWP_UNKNOWN_WORD_PRONOUNCEABLE The word is pronounceable by the SR engine, but is not located in the lexicon and/or the engine's dictionary. 
SPWP_KNOWN_WORD_PRONOUNCEABLE The word is pronounceable by the SR engine, and is located in the lexicon and/or the engine's dictionary.

Return values

Value Description
S_OK Function completed successfully.
E_POINTER Either pszWord or pfPronounceable is invalid or bad.
FAILED (hr) Appropriate error message.

Remarks

The exact implementation and usage for the SR engine's dictionary and pronounceable words may vary between engines. For example, an SR engine may attempt to pronounce all words passed using ::IsPronounceable, even if it is not located in the lexicon or the dictionary, it would rarely or never, return SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE.

Typically, there are two scenarios when an application might use the method ::IsPronounceable.

If an application is using a number of specialized or uncommon words (e.g., legal, medical, or scientific terms), the application may want to verify that the words are contained in either the lexicon (see also ISpLexicon) or the SR engine's dictionary. If the words are not contained in the lexicon or the dictionary (even if they are pronounceable), the application can add them to the lexicon to improve the chances of a successful recognition.

An application may also want to verify that the SR engine will actually recognize the words in a CFG (even though loading the CFG succeeded). If the SR engine returns SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE, the application can update the lexicon pronunciation entry (see ISpLexicon).

Example

The following code snippet illustrates the use of ISpRecoGrammar:IsPronounceable. The words used are examples only, as the pronounceability by different SR engines may vary. See Remarks section.


// Declare local identifiers:
HRESULT                      hr = S_OK;
CComPtr<ISpRecoGrammar>      cpRecoGrammar;
SPWORDPRONOUNCEABLE          wordPronounceable;

// Check if a common word is pronounceable.
hr = cpRecoGrammar->IsPronounceable(L"hello", &wordPronounceable;);

if (SUCCEEDED(hr))
{
   // wordPronounceable is probably equal to SPWP_KNOWN_WORD_PRONOUNCEABLE.

   // Check if an uncommon or imaginary word is pronounceable.
   hr = cpRecoGrammar->IsPronounceable(L"snork", &wordPronounceable;);
}

if (SUCCEEDED(hr))
{
   // wordPronounceable is probably equal to SPWP_UNKNOWN_WORD_PRONOUNCEABLE.

   // Check if a non-word or imaginary word is unpronounceable.
   hr = cpRecoGrammar->IsPronounceable(L"lpdzsd", &wordPronounceable;);
}

if (SUCCEEDED(hr))
{
   // wordPronounceable is probably equal to SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE.
}