Microsoft语音平台:“SPF_NLP_SPEAK_PUNC”不起作用

时间:2014-03-06 02:58:36

标签: text-to-speech sapi punctuation microsoft-speech-platform

我正在使用语音平台进行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;   
}

但这并不像预期的那样有效。 这输出“这是一个句子”的演讲,而不是发出“句号”。

请帮帮我。

1 个答案:

答案 0 :(得分:1)

查看您的代码,您似乎正在使用服务器语音。那些声音(据我所知)不支持SPF_NLP_SPEAK_PUNC