Share via


ISpRecoGrammar::IsPronounceable (SAPI 5.4)

Microsoft Speech API 5.4

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
SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE
SPWP_UNKNOWN_WORD_PRONOUNCEABLE
SPWP_KNOWN_WORD_PRONOUNCEABLE

Return values

Value
S_OK
E_POINTER
FAILED (hr)

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).

See also ISpSREngine::IsPronounceable for more information on the SR engine's role.

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.
}