Click to See Complete Forum and Search --> : Voice Synthesis


suriyamohan
October 27th, 2002, 01:32 AM
hi,

My doubt is as follows. The following sample code for voice synthesis works well in Windows 98. But does not support Windows NT. The compiler doesn't specify any compiler error while compiling. And also no run time error.When the program is executed it outputs nothing.So i checked for REGDB_E_CLASSNOTREG (class not registered) error in the last if statement.The if condition is satisfied. Where is the mistake? Help me in this regard.

main(){
HRESULT hr;
UpdateData();

ISpVoice * pVoice = NULL;

if (FAILED(::CoInitialize(NULL)))
{
AfxMessageBox("Error to intiliaze COM");
return;
}

hr = CoCreateInstance(
CLSID_SpVoice, //Class identifier (CLSID) of the object NULL, //Pointer to whether object is or isn't part
//of an aggregate
CLSCTX_ALL, //Context for running executable code
IID_ISpVoice, //Reference to the identifier of the interface
(void **)&pVoice //Address of output variable that receives
// the interface pointer requested inIID_ISpVoice
);

if( hr == REGDB_E_CLASSNOTREG )
{
AfxMessageBox("A specified class is not registered in the registration database");
// this is the error
}
else
{
AfxMessageBox("CoCreateInstance Succeeded");
hr = pVoice->Speak(L"Hello World",
0,
NULL
);
pVoice->Release();
pVoice = NULL;
}
::CoUninitialize();
}