Using Speech

Posts 1–15 of 16 · Page 1 of 2
Using Speech
Well this is the code to use text to speech:
Code:
#define COMPLETE 0
bool Voice_Start_Up()
{ISpVoice * pVoice = NULL;

    if (FAILED(::CoInitialize(NULL)))
        return FALSE;

    HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
    if( SUCCEEDED( hr ) )
    {
        hr = pVoice->Speak(L"Hello. I am iRobot.", 0, NULL);

        pVoice->Release();
        pVoice = NULL;
    }
    ::CoUninitialize();
	return COMPLETE;
}
What would I have to change to use this throughout my entire program?

I am calling this function from main and I want to be able to use it in Main and other functions. So far I know that I have to remove this:
pVoice->Release();
pVoice = NULL;
::CoUninitialize();

What should I do?
Didn't you just ask this? Or was that someone else?
pVoice->Speak(L"Hello. I am a shitty non-realistic sound that should not be used.", 0, NULL);

Quote Originally Posted by Stephen View Post
Didn't you just ask this? Or was that someone else?
I'm almost 100% sure it was him.
Quote Originally Posted by freedompeace View Post
pVoice->Speak(L"Hello. I am a shitty non-realistic sound that should not be used.", 0, NULL);



I'm almost 100% sure it was him.
Whoa, relax buddy, his last question regarding this was that his code wasn't working for some reason.
Quote Originally Posted by Void View Post
Whoa, relax buddy, his last question regarding this was that his code wasn't working for some reason.
Atleast he was right
Quote Originally Posted by Void View Post
Whoa, relax buddy, his last question regarding this was that his code wasn't working for some reason.
Sorry :L

Was a little .. off-mood because of something?
Personally I didn't get the question.
I actually have never asked a question about Text-Speech this is the first time. Zane Slayman asked about this before.

Im going to try and simplify this question:

I basically want to be able to use speech throughout my entire program in my functions.
make 'ISpVoice * pVoice;' a global variable(not in any function) then you'll be able to access it from anywhere
Nope. That was the first thing I tried.
Quote Originally Posted by aanthonyz View Post
Nope. That was the first thing I tried.
Well it's the only thing that will work so you must not have done it right. No offense. Make sure you initialize if before other functions use it.
Sorry about that ><

Quote Originally Posted by aanthonyz View Post
Nope. That was the first thing I tried.
Are you trying to call it from another thread? If so, that's your problem, because you wouldn't have intialised the COM object library on that thread, and, it (usually) wouldn't have been set as an STA.

I still think you shouldn't use the MS Speech API. There are heaps better, like Google's or AT&T's :)
Quote Originally Posted by freedompeace View Post
Sorry about that ><



Are you trying to call it from another thread? If so, that's your problem, because you wouldn't have intialised the COM object library on that thread, and, it (usually) wouldn't have been set as an STA.

I still think you shouldn't use the MS Speech API. There are heaps better, like Google's or AT&T's
Thanks. I realized that yesterday, so I just decided to initialize the COM a bunch of times lol...

Do Google's or AT&T's have tutorials on how to set it up?

The only reason im using MS Speech API is because it has a tutorial on how to implement it.
Quote Originally Posted by aanthonyz View Post
Thanks. I realized that yesterday, so I just decided to initialize the COM a bunch of times lol...

Do Google's or AT&T's have tutorials on how to set it up?

The only reason im using MS Speech API is because it has a tutorial on how to implement it.
Initializing COM on threads you don't use it on isn't a good thing to be doing, just beecause it wastes memory, but that shouldn't really matter right now.

Well, they aren't strictly APIs, but they're uses by the respective companis in their products to produce speech synthesis (in Android, for example). You can leverage this technology

I don't think there are any tutorials but some code is available on the Internet.
Posts 1–15 of 16 · Page 1 of 2

Post a Reply

Tags for this Thread

None

Talk with us