0

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.

higuri
  • 28
  • 4

1 Answers1

1

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.

Eric Brown
  • 13,774
  • 7
  • 30
  • 71
  • Thank you for your reply, and I'm sorry for my late reply. Do you mean that 'Server voice' is 'Microsoft Text-to-Speech Engine'? I use it, downloaded from [Microsoft](http://www.microsoft.com/en-us/download/details.aspx?id=27224). Are there any other options to use en-US voice on Microsoft Speech Platform? – higuri Mar 11 '14 at 08:38
  • Microsoft has two distinct sets of TTS engines, optimized for different purposes. These have the exact same user-level API; you select the TTS engine via the token. If you use the desktop engine (e.g., use the token `"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech\Voices\Tokens\TTS_MS_EN-US_DAVID_11.0"`, then you'll have a voice that supports `SPF_NLP_SPEAK_PUNC`. If you went into more detail about *why* you need the Speech Server voices, that would help, too. – Eric Brown Mar 11 '14 at 16:53
  • Thank you for the detailed explanation. I got a voice that supports `SPF_NLP_SPEAK_PUNC` by using _desktop_ voice engine (in my case, MS-Anna). There was no particular reason why I had used _server_ voice. I didn't know the difference between desktop version and server version. So [your another answer](http://stackoverflow.com/a/17623740/3386195) was also helpful for me. Thanks! – higuri Mar 12 '14 at 00:58