M
mutant
Guest
Hi.
I downloaded Speech SDK from MS site just to try all that cool stuff you can do with it . The project is a Managed Application. I use garbage collector public class to create a form, add event handler. I cant set the global function as an event handler so i create another function that points to the global function. The function is global because it doesnt seem to do what its supposed to if its in the form class. Its all good, no errors during debugging and when i try to make the app speak a sentence after clicking a button it doesnt do anything. The only way it works is if i put the speaking in main function but that sucks cause cant do much with it if its in main cause its gonna start by tself.
Here is some code:
My button event handler:
My function that initializes the function that will do the speaking:
And my speaking function (this is the global one):
ANY help would be appreciated.
BTW. Im the first one to post in VC++ forum
I downloaded Speech SDK from MS site just to try all that cool stuff you can do with it . The project is a Managed Application. I use garbage collector public class to create a form, add event handler. I cant set the global function as an event handler so i create another function that points to the global function. The function is global because it doesnt seem to do what its supposed to if its in the form class. Its all good, no errors during debugging and when i try to make the app speak a sentence after clicking a button it doesnt do anything. The only way it works is if i put the speaking in main function but that sucks cause cant do much with it if its in main cause its gonna start by tself.
Here is some code:
My button event handler:
Code:
btnSpeak->Click += new EventHandler(this,&Speaker::CheckText);
My function that initializes the function that will do the speaking:
Code:
void CheckText(Object* pSender, EventArgs* pArgs)
{
SpeakText();
}
And my speaking function (this is the global one):
Code:
int SpeakText()
{
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"SPEAK GODDAMIT!!!!!!", SPF_IS_XML, NULL );
pVoice->Release();
pVoice = NULL;
}
::CoUninitialize();
return TRUE;
}
ANY help would be appreciated.
BTW. Im the first one to post in VC++ forum