Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ISpLexicon::AddPronunciation (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3

ISpLexicon::AddPronunciation

ISpLexicon::AddPronunciation adds word pronunciations and parts of speech (POS) to the user lexicon. .

HRESULT AddPronunciation(
   LPCWSTR          *pszWord,
   LANGID            LangID,
   SPPARTOFSPEECH    ePartOfSpeech,
   PCSPPHONEID      *pszPronunciation
);

Parameters

pszWord
[in] The word to add.
LangID
[in] The language ID of the word. The speech user default will be used if LANGID is omitted. Length must be equal to or less than SP_MAX_WORD_LENGTH.
ePartOfSpeech
[in] The part of speech of type SPPARTOFSPEECH.
pszPronunciation
[in] Null-terminated pronunciation of the word in the NUM phone set. Multiple pronunciations may be added for a single word.  The length must be equal to or less than SP_MAX_PRON_LENGTH.  pszPronunciation may be NULL.

Return values

ValueDescription
S_OKFunction completed successfully.
E_INVALIDARGAt least one of the parameters is not valid.
SP_ALREADY_IN_LEXThe same pronunciation of the word already exists in the user lexicon.
SPERR_APPLEX_READ_ONLYCannot add a word to application lexicon.
SPERR_UNINITIALIZEDThe interface has not been initialized.
E_OUTOFMEMORYExceeded available memory.
FAILED(hr)Appropriate error message.

Remarks

See the documentation on ISpPhoneConverter for more information on phone sets.

SAPI will not modify the word if spelling, pronunciation, and POS are the same as an existing entry in the user lexicon. A word can be added without pronunciation by passing in NULL as the pszPronunciation

Example

The following is an example of AddPronunciation.


// Declare local identifiers:
HRESULT                      hr = S_OK;
CComPtr<ISpPhoneConverter>   cpPhoneConv;
CComPtr<ISpLexicon>          cpLexicon;
LANGID                       langidUS;
SPPHONEID                    wszId[SP_MAX_PRON_LENGTH];

hr = cpLexicon.CoCreateInstance(CLSID_SpLexicon);

// 0x409 for English.
langidUS = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);

if(SUCCEEDED(hr))
{
   hr = SpCreatePhoneConverter(langidUS, NULL, NULL, &cpPhoneConv;);
}

if(SUCCEEDED(hr))
{
   hr = cpPhoneConv->PhoneToId(L"r eh d", wszId);
}
if(SUCCEEDED(hr))
{
   hr = cpLexicon->AddPronunciation(L"red", langidUS, SPPS_Noun, wszId);
}

if (SUCCEEDED(hr))
{
   // Do stuff here.
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.