[Help]C++ Text to Speech

Posts 1–15 of 15 · Page 1 of 1
[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.

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;
}
I imagine this would take alot more code...But idk..
Ask Apoc91 tho he's done it
Quote Originally Posted by whit View Post
I imagine this would take alot more code...But idk..
Ask Apoc91 tho he's done it
Ok thanks whit, its so much easier in Visual Basics. Mhmm
why is the code you provided not working?
That's text-to-speech, not speech-to-text...

Plus the MS TTS is really shitty, they all sound like robots
wth kinda call is this?
Code:
::CoInitialize(NULL)
Quote Originally Posted by why06 View Post
wth kinda call is this?
Code:
::CoInitialize(NULL)
calling the global constructor CoInitialize, perhaps the contructor is within another instance of a class using the same name but locally, thus, you would want to call using the global instance.

idk if that makes any sense, i don't really use this method often.
Quote Originally Posted by why06 View Post
wth kinda call is this?
Code:
::CoInitialize(NULL)
Global function call to intialise a COM object on current thread.
k, but what's with the scope resolution operator


EDIT: Oh wait I get it. I had to go back and learn C++ again, but I get it. Guess it's sorta like the "this" keyword in Java
This code is sorta something i used to get myself started but i have yet to have it say something to me. When i press a button or when something is activated!
Quote Originally Posted by NOOBJr View Post
This code is sorta something i used to get myself started but i have yet to have it say something to me. When i press a button or when something is activated!
You're not doing the keycheck in a loop, therefor the code inside the keycheck is never executed
Quote Originally Posted by Hell_Demon View Post
You're not doing the keycheck in a loop, therefor the code inside the keycheck is never executed
O..... Ok ill work on it thanks!
I have a working source code. So maybe ill make some error's in it and send it to u?
Quote Originally Posted by NexonShock View Post
I have a working source code. So maybe ill make some error's in it and send it to u?
Ya please do!
Quote Originally Posted by NexonShock View Post
I have a working source code. So maybe ill make some error's in it and send it to u?
I think your Trolling..
If you are were not impressed..
Posts 1–15 of 15 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us