// these 2 control the audio destination ( to the wave file )
typedef TComInterface<TIAudioDest> TIWaveOut;
typedef TCoClassCreatorT<TIWaveOut, TIAudioDest, &TCLSID_IAudio,
&TIID_IAudio> TWaveCreator;
// these are for the speech engine
typedef TComInterface<ITTSFind> TITTSEnumerator;
typedef TCoClassCreatorT<TITTSEnumerator, ITTSFind,
&CLSID_TTSEnumerator,
&IID_ITTSFind> TEnumCreator;
typedef TComInterface<IVoiceText> TVoiceText;
typedef TCoClassCreatorT<TVoiceText, IVoiceText, &CLSID_VTxt,
&IID_IVoiceText> TVoiceTextCreator;
typedef TComInterface<ITTSCentral, &IID_ITTSCentral> TITTSCentral;
typedef TComInterface<ITTSAttributes, &IID_ITTSAttributes>
TITTSAttributes;
...
TIWaveOut WaveOut;
TITTSCentral pITTSCentral;
TITTSAttributes speed;
...
void __fastcall TWorker::ConnectTTS()
{
//TODO: Add your source code here
try {
WaveOut = TWaveCreator::Create();
TITTSEnumerator TTSEnum = TEnumCreator::Create();
TTSMODEINFO ttsResult; // final result
TTSMODEINFO ModeInfo;
memset( &ModeInfo, 0, sizeof( ModeInfo ) );
strcpy( ModeInfo.szModeName, "Mary (for Telephone)" );
// strcpy( ModeInfo.szModeName, "English-American: Shelley-Tel
(Adult Female for Telephone)" );
//"Adult Male #1, American English (TruVoice)" );
//"English-American: Reed-Tel (Adult Male for Telephone)" );
HRESULT hRes = TTSEnum->Find( &ModeInfo, NULL, &ttsResult );
if ( !SUCCEEDED( hRes ))
return;
// Pass off the audio file interface as an IUnknown (since it is
one)
// Should do select now
hRes = TTSEnum->Select( ttsResult.gModeID, &pITTSCentral, WaveOut
);
if ( !SUCCEEDED( hRes ) )
return;
pITTSCentral->AddRef();
speed = pITTSCentral;
DWORD sp = 0;
speed->SpeedGet( &sp );
// register so we get the notifications
std::auto_ptr<CTestNotify> tmp( new CTestNotify( &TAPICallback )
);
Notify = tmp;
pITTSCentral->Register( (void*)Notify.get(), IID_ITTSNotifySink,
&m_dwRegKey );
}
catch( ... ) {
ErrorCallback( NoTTS );
}
}
Note, that these are pieces of code, not a complete solution. But it
should give you a good start.
HTH,
Alex
Kow Kok Kiat wrote:
[snip]
--
From: Kok Kiat