Export (0) Print
Expand All

SPWORDPRONUNCIATIONLIST (SAPI 5.4)

Speech API 5.4
Microsoft Speech API 5.4

SPWORDPRONUNCIATIONLIST

SPWORDPRONUNCIATIONLIST is used with ISpLexicon::GetPronunciations to list possible variations in pronunciation for a given word.

typedef struct SPWORDPRONUNCIATIONLIST
{
    ULONG                   ulSize;
    BYTE                   *pvBuffer;
    SPWORDPRONUNCIATION    *pFirstWordPronunciation;
} SPWORDPRONUNCIATIONLIST;

Members

ulSize
Size of the pronunciation buffer, in bytes.
pvBuffer
Pointer to the buffer for all pronunciations.
pFirstWordPronunciation
Pointer to the first in a linked list of SPWORDPRONUNCIATION structures within pvBuffer.

Remarks

This structure is the start of a linked list of SPWORDPRONUNCIATION structures and contains the size and actual buffer of all subsequent pronunciations.

Call ZeroMemory before using SPWORDPRONUNCIATIONLIST to initialize it, and call CoTaskMemFree(spwordpronlist.pvBuffer) to free the buffer allocated during the calls. The pvBuffer need not (and should not) be freed between the calls.  ISpLexicon::GetPronunciations will reuse the buffer for efficiency and reallocate when necessary.

Example

The following example is a code fragment demonstrating the use and creation of SPWORDPRONUNCIATIONLIST.

    SPWORDPRONUNCIATIONLIST spwordpronlist;
    memset(spwordpronlist, 0, sizeof(spwordpronlist));

    pISpLexicon->GetPronunciations(L"resume", 0, 0, &spwordpronlist);
    for (SPWORDPRONUNCIATION *pwordpron = spwordpronlist.pFirstWordPronunciation;
         wordpron != NULL;
         wordpron = pwordpron->pNextWordPronunciation)
    {
        DoSomethingWith(pwordpron->ePartOfSpeech, pwordpron->szPronunciation);
    }

    pISpLexicon->GetPronunciations(L"record", 0, 0, &spwordpronlist);
    // repeat the for loop above to process the pronunciations

    CoTaskMemFree(spwordpronlist.pvBuffer);

The following helper class will ensure the correct usage of SPWORDPRONUNCIATIONLIST.

class CSpPronList : public SPWORDPRONUNCIATIONLIST
{
public:
    CSpPronList()
    {
        ZeroMemory(static_cast<SPWORDPRONUNCIATIONLIST*>(this), sizeof(SPWORDPRONUNCIATIONLIST));
    }
    ~CSpPronList()
    {
        CoTaskMemFree(pvBuffer);
    }
};

Using the helper class, the above sample becomes:

    CSpPronList spwordpronlist;

    pISpLexicon->GetPronunciations(L"resume", 0, 0, &spwordpronlist);
    for (SPWORDPRONUNCIATION *pwordpron = spwordpronlist.pFirstWordPronunciation;
         wordpron != NULL;
         wordpron = pwordpron->pNextWordPronunciation)
    {
        DoSomethingWith(pwordpron->ePartOfSpeech, pwordpron->szPronunciation);
    }

    pISpLexicon->GetPronunciations(L"record", 0, 0, &spwordpronlist);
    // repeat the for loop above to process the pronunciations

 

Show:
© 2014 Microsoft