Note
Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.
Microsoft Speech Platform
ISpRecoGrammar::IsPronounceable
ISpRecoGrammar::IsPronounceable calls the speech recognition engine object to determine if the word has a pronunciation.
<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT IsPronounceable(</strong> <strong>LPCWSTR</strong> *<em>pszWord</em>, <strong><a runat="server" href="jj127488(v=msdn.10).md">SPWORDPRONOUNCEABLE</a></strong> *<em>pfPronounceable</em> <strong>);</strong> </pre>
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 SR engine's internal lexicon or in any referenced custom lexicons. |
SPWP_UNKNOWN_WORD_PRONOUNCEABLE | The word is pronounceable by the SR engine, but is not located in the SR engine's internal lexicon or in any referenced custom lexicons. |
SPWP_KNOWN_WORD_PRONOUNCEABLE | The word is pronounceable by the SR engine, and is located in the SR engine's internal lexicon and/or in at least one referenced custom lexicon. |
Return Values
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_POINTER | Either pszWord or pfPronounceable is not valid or bad. |
FAILED (hr) | Appropriate error message. |
Remarks
The exact implementation and usage for the speech recognition (SR) engine's internal lexicon and pronounceable words may vary between engines. For example, an SR engine may attempt to pronounce all words passed using ::IsPronounceable, even for words not contained in the SR engine's internal lexicon or in a custom application lexicon. Typically, an SR engine does not return SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE.
The following are two scenarios when an application might use the method ::IsPronounceable.
If an application is using a number of specialized or uncommon words (such as legal, medical, or scientific terms), the application may want to verify that the words are contained in either its custom application lexicon or the in the SR engine's internal lexicon. If the words are not contained in any lexicon (even if they are pronounceable), you can add the words (and their pronunciations) to the application 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 context-free grammar (CFG), even though the CFG loaded successfully. If the SR engine returns SPWP_UNKNOWN_WORD_UNPRONOUNCEABLE, you may want to update the pronunciation entry in the lexicon (see Using Lexicons with the Microsoft Speech Platform).
Example
The following code snippet illustrates the use of ISpRecoGrammar:IsPronounceable. The words used are examples only, as the ability of different SR engines to pronounce specific words may vary.
`
// 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. } `