Article View: borland.public.cppbuilder.nativeapi
Article #952BCB and SAPI v5
From: Marc
Date: Wed, 21 Nov 2007 17:47
Date: Wed, 21 Nov 2007 17:47
112 lines
3496 bytes
3496 bytes
Hi all
So here is what I did so far:
I spent the last three days trying to use the MS SAPI SDK 5.1. It installed
all right and the samples in VB work OK.
Using the code snipped of my last post I was able to let it speak through my
speaker.
But since then I am hitting one problem after the other.
When I include the "sphelper.h" needed for the SPBindToFile function, I get
plenty of errors in the *.h files.
IE if I set the _DEBUG option I get the error _CRTDBG_MODE_DEBUG not defined
in the sebug.h and many more errors complaining about missing definitions
?!?!?
When I disable the debugger (not really a solution in the long term) I am
able to compile (after a couple of adaptations to the sphelper.h)
Now I used the attached code and tried to write the TTS to a file.
Unfortunately it fails every time with the call to SPBindToFile (Error =
E_INVALIDARG).
I had a look through all of www.deja.com, did Google searches and played
around myself with the parameters => no success.
Therefore my questions:
1)Has anyone ever successfully used SAPI v5 with BCB6 and was able to
compile the sphelper.h in _DEBUG mode ?
2)Has anyone ever successfully used the SPBindToFile function ?
I was also looking at using the MS OCXs, but Microsoft does not ship them in
SAPI v5 anymore and I do not really want to go back to SAP v4.
Rds
Marc
******************************************************
void TSpeech::SpeakToFile(String Words, String sFileName)
{
HRESULT hr = S_OK;
ISpVoice *cpVoice;
ISpStream *cpStream;
CSpStreamFormat *cAudioFmt;
//Create a SAPI Voice
hr = cpVoice.CoCreateInstance( CLSID_SpVoice );
//Set the audio format
if(SUCCEEDED(hr))
{
hr = cAudioFmt.AssignFormat(SPSF_22kHz16BitMono);
}
//Call SPBindToFile, a SAPI helper method, to bind the audio stream to the
file
if(SUCCEEDED(hr))
{
hr = SPBindToFile( L"c:\\ttstemp.wav", SPFM_CREATE_ALWAYS,
&cpStream, & cAudioFmt.FormatId(),cAudioFmt.WaveFormatExPtr() );
}
//=> FAILS HERE WITH INVALIARG ****************************
//set the output to cpStream so that the output audio data will be stored
in cpStream
if(SUCCEEDED(hr))
{
hr = cpVoice->SetOutput( cpStream, TRUE );
}
//Speak the text "hello world" synchronously
if(SUCCEEDED(hr))
{
hr = cpVoice->Speak( L"Hello World", SPF_DEFAULT, NULL );
}
//close the stream
if(SUCCEEDED(hr))
{
hr = cpStream->Close();
}
//Release the stream and voice object
cpStream.Release ();
cpVoice.Release();
}
Technical Details
Message-ID:
<47446f75$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,67677465280073fd,start X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Marc" <info@mawnet.com> From: "Marc" <info@mawnet.com> Newsgroups: borland.public.cppbuilder.nativeapi Subject: BCB and SAPI v5 Date: Wed, 21 Nov 2007 18:47:33 +0100 Lines: 114 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 83.76.7.81 Message-ID: <47446f75$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1195667317 83.76.7.81 (21 Nov 2007 09:48:37 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail