Using Speech
Well this is the code to use text to speech:
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?
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;
}
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?



