Question

I'm using Speech Platform for TTS(text-to-speech).

I want to get speech outputs with pronunciation of symbols (punctuation marks).

MSDN says:

 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

so, I wrote code below:

#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;   
}

But this doesn't work as expected. This outputs speech of "this is a sentence", not pronouncing "period".

Please help me.

Was it helpful?

Solution

Looking at your code, it appears you're using the Server voices. Those voices (as far as I can tell) don't support SPF_NLP_SPEAK_PUNC.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top