[Help]C++ Text to Speech
In C++ does anyone know how to do text to speech?
For example if this button is clicked Say" Button 1 on"
Ive googled it a number of times and kept getting all the same answers and they dont work. Here is the code i gathered from google.
For example if this button is clicked Say" Button 1 on"
Ive googled it a number of times and kept getting all the same answers and they dont work. Here is the code i gathered from google.
Code:
#include <sapi.h>
int main(int argc, char* argv[])
{
ISpVoice * pVoice = NULL;
if (FAILED(::CoInitialize(NULL)))
return FALSE;
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if( SUCCEEDED( hr ) )
{
if(GetAsyncKeyState(VK_INSERT)){
hr = pVoice->Speak(L"Hello World", 0, NULL);
// Change pitch
// hr = pVoice->Speak(L"This sounds normal <pitch middle = '-10'/> but the pitch drops half way through", SPF_IS_XML, NULL );
pVoice->Release();
pVoice = NULL;
}
}
::CoUninitialize();
return TRUE;
}

