Share via


ISpLexicon::GetPronunciations

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

This method gets pronunciations and parts of speech for a word. The method retrieves lexicon pronunciation information in the following order:

  1. Pronunciation from user lexicon (could have multiple pronunciations)
  2. Pronunciation from application lexicon(s) (could have multiple pronunciations)
  3. Pronunciation from the added lexicons in the same order the lexicons were added.

The expected order of priority is the same as that retrieved from the previous list by GetPronunciations.

Syntax

HRESULT GetPronunciations(
  const WCHAR* pszWord,
  LANGID LangID,
  DWORD dwFlags,
  SPWORDPRONUNCIATIONLIST* pWordPronunciationList
);

Parameters

  • pszWord
    [in] Pointer to a search keyword. The length must be less than or equal to SP_MAX_WORD_LENGTH.
  • LangID
    [in] Language identifier of the word. Can be zero to indicate that the word can be of any LANGID.
  • dwFlags
    [in] Pointer to bitwise flags of type SPLEXICONTYPE indicating the lexicons searched for this word.
  • pWordPronunciationList
    [in, out] Pointer to an SPWORDPRONUNCIATIONLIST structure identifying the retrieved pronunciations and parts of speech.

Return Value

The following table shows the possible return values.

Value Description

S_OK

Function completed successfully.

SP_WORD_EXISTS_WITHOUT_PRONUNCIATION

The word exists but does not have a pronunciation.

E_POINTER

pWordPronunciationList is not a valid write pointer.

E_INVALIDARG

At least one of the parameters is invalid or bad.

E_OUTOFMEMORY

Exceeded available memory.

SPERR_UNINITIALIZED

The interface has not been initialized.

SPERR_NOT_IN_LEX

Word is not found in the lexicon.

FAILED(hr)

Appropriate error message.

Example

The following example is a code fragment demonstrating the use of this method.

SPWORDPRONUNCIATIONLIST spwordpronlist; 
memset(&spwordpronlist, 0, sizeof(spwordpronlist)); 
hr = pISpLexicon->GetPronunciations(L"resume", 409, eLEXTYPE_USER |
eLEXTYPE_APP, &spwordpronlist);
//test for results
if( !SUCCEEDED(hr)) return;
for (
    SPWORDPRONUNCIATION pwordpron = pwordpronlist->pFirstWordPron;
    wordpron != NULL;
    wordpron = pwordpron->pNextWordPron
    )
{
   DoSomethingWith(pwordpron->ePartOfSpeech, 
                   pwordpron->szPronunciation);
}
//free all the buffers
CoTaskMemFree(spwordpronlist.pvBuffer);

Requirements

Header sapi.h, sapi.idl
Library sapilib.lib
Windows Embedded CE Windows CE .NET 4.1 and later

See Also

Reference

ISpLexicon
SAPI Interfaces