ISpObjectTokenCategory::SetId returns failed hr

0

I am using Visual Studio Express 2013 for desktop and facing an issue for Text-To-Speech conversion in female voice. To do that I have used ISpObjectTokenCategory::EnumTokens.

I am using hr = pObjectTokenCategory->SetId(SPCAT_VOICES, false) to do so. But the hr fails with the value 0x8004503a. If I use other Token Category IDs such as SPCAT_RECOGNIZERS hr is S_OK. It only fails for SPCAT_VOICES category.

Following is my C++ code-

hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_INPROC_SERVER, __uuidof(ISpVoice), (void**)&pSpVoice);
if (FAILED(hr))
{
    cout << "Failed to get pSpVoice interface by CoCreateInstance" << endl;
    return hr;
}

hr = CoCreateInstance(CLSID_SpObjectTokenCategory, NULL, CLSCTX_INPROC_SERVER, __uuidof(ISpObjectTokenCategory), (void**)&pObjectTokenCategory);
if (FAILED(hr))
{
    cout << "Failed to get ObjectTokenCategory by cocreateInstance" << endl;
    return hr;
}

hr = pObjectTokenCategory->SetId(SPCAT_VOICES, false);
if (FAILED(hr))
{
    cout << "Failed to set Voice Category" << endl;
    return hr;
}

hr = pObjectTokenCategory->EnumTokens(L"Language=409,Gender=Female;", NULL, &pSpEnumTokens);
if (FAILED(hr))
{
    cout << "Failed to get EnumTokens" << endl;
    return hr;
}

How can this be resolved for SP_VOICES category?

c++
com
sapi
asked on Stack Overflow Mar 5, 2015 by kk2

1 Answer

0

0x8004503a is SPERR_NOT_FOUND (you can find the SAPI error definitions in sperror.h).

This indicates that the SPCAT_VOICES registry key isn't found; are you sure you have TTS voices (of any sort) installed?

answered on Stack Overflow Mar 5, 2015 by Eric Brown

User contributions licensed under CC BY-SA 3.0