I now use following function to realize a TTS service.
int tts(LPCWSTR text){
::CoInitialize(NULL);
CLSID CLSID_SpVoice;
CLSIDFromProgID(_T("SAPI.SpVoice"), &CLSID_SpVoice);
ISpVoice *pSpVoice = NULL;
IEnumSpObjectTokens *pSpEnumTokens = NULL;
if (FAILED(CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_INPROC_SERVER, IID_ISpVoice, (void**)&pSpVoice))){
return -1;
}
if (SUCCEEDED(SpEnumTokens(SPCAT_VOICES, NULL, NULL, &pSpEnumTokens))){
ISpObjectToken *pSpToken = NULL;
SpFindBestToken(SPCAT_VOICES, L"Gender=Male", L"Name=Microsoft Simplified Chinese", &pSpToken);
pSpVoice->SetVoice(pSpToken);
pSpVoice->Speak(text, SPF_DEFAULT, NULL);
pSpEnumTokens->Release();
}
pSpVoice->Release();
::CoUninitialize();
return 0;
}
Is it possible for me to get the elapsed time of each character being spoken? Or is it constant (if the speech rate is set)? The purpose is that I want to show some facial animations to match the speech...
Aucun commentaire:
Enregistrer un commentaire