First of all, thank you very much for replying, people.
I have read the SAPI SDK help. In fact, I am trying to at least compile the code mintioned in Text-to-Speech Tutorial (SAPI 5.3) at "Step 4":
This code works in C++:
Code:
#include <stdafx.h>
#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 ) )
{
hr = pVoice->Speak(L"Hello world", 0, NULL);
pVoice->Release();
pVoice = NULL;
}
::CoUninitialize();
return TRUE;
}
The closest "translation" of the code above into C code as following (this produces the least amount of errors during compiling so far):
Code:
#include <sapi.h>
int main(int argc, char* argv[])
{
HRESULT hr;
ISpVoice *pVoice = NULL;
if (FAILED(CoInitialize(NULL)))
printf("Error to intiliaze COM");
else
printf("ISpVoice Initialized\n\n");
hr = CoCreateInstance(&CLSID_SpVoice, NULL, CLSCTX_ALL, &IID_ISpVoice, (void **)&pVoice);
if(SUCCEEDED(hr))
{
hr = pVoice->Speak("Hello world", SPF_DEFAULT, NULL);
if ( pVoice != NULL )
pVoice->Release();
pVoice = NULL;
}
CoUninitialize();
return 0;
}
When compiling the second blob of code above I get two errors:
Code:
error C2039: 'Speak' : is not a member of 'ISpVoice'
and
error C2039: 'Release' : is not a member of 'ISpVoice'
and I tried and tried and I can't get it to work in C in any way.
[EDIT]: and if I use just
Code:
...
hr = Speak("Hello world", SPF_DEFAULT, NULL);
...
then it says "Speak()" is undefined. Same with "Release()" function.