我正在使用语音平台进行 TTS(文本到语音)。
我想获得带有符号(标点符号)发音的语音输出。
MSDN 说:
ISpVoice::Speak speaks the contents of a text string or file.
HRESULT Speak(
LPCWSTR *pwcs,
DWORD dwFlags,
ULONG *pulStreamNumber
);
...
dwFlags
[in] Flags used to control the rendering process for this call. The flag values are contained in the SPEAKFLAGS enumeration.
...
http://msdn.microsoft.com/en-us/library/speechplatform_ispvoice_speak.aspx
SPEAKFLAGS
...
SPF_NLP_SPEAK_PUNC
Punctuation characters should be expanded into words (for example, "This is a sentence." would become "This is a sentence period").
...
http://msdn.microsoft.com/en-us/library/speechplatform_speakflags.aspx
所以,我在下面写了代码:
#define TOKEN_ID L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Speech Server\\v11.0\\Voices\\Tokens\\TTS_MS_en-US_Helen_11.0"
int main(void) {
CoInitialize(NULL);
ISpVoice* spVoice = NULL;
CoCreateInstance(CLSID_SpVoice, NULL,
CLSCTX_INPROC_SERVER, IID_ISpVoice, (void**)&spVoice);
ISpObjectToken* token = NULL;
SpGetTokenFromId(TOKEN_ID, &token, FALSE);
spVoice->SetVoice(token);
spVoice->Speak(L"This is a sentence.",
SPF_DEFAULT | SPF_NLP_SPEAK_PUNC, NULL);
CoUninitialize();
return 0;
}
但这并没有按预期工作。这会输出“这是一个句子”的语音,而不是“句号”的发音。
请帮我。