Get language of the current TTS voice

767 Views Asked by At

What's the best way to get the language of the current voice that the TTS engine will use?

I thought that I'd use something like

ISpObjectToken *pToken = NULL;
HRESULT hResult;
CComPtr<ISpVoice>   cpVoice;
hResult = cpVoice.CoCreateInstance( CLSID_SpVoice );
hResult = cpVoice->GetVoice(&pToken);

but I'm not sure how to extract LangId from this to determine the current language. The guides I've seen all seem to address changing the voice. I'd prefer to keep the current voice and then to do something tailored to the voice that the user has already selected for their system.

1

There are 1 best solutions below

0
On

sphelper.h in the Windows SDK has a helper function

SpGetLanguageFromToken(ISpObjectToken* pToken, LANGID* pLangid)

that should do what you want.