🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #957

Re: BCB and SAPI v5

#957
From: Remy Lebeau (TeamB)
Date: Wed, 21 Nov 2007 22:40
176 lines
6694 bytes
"Marc" <info@mawnet.com> wrote in message 
news:4744a4e3$1@newsgroups.borland.com...

> You are right, I made a mistake when I pasted my sample as I
> cleaned it for display purposes.

Always copy/paste your actual code.  It reduces confusion and errors.

> I tried to implement the sample at
> http://msdn2.microsoft.com/en-us/library/ms717065.aspx

You are not using the example exactly as it is provided.  For instance, you 
are not making use of the CComPtr class to manage your pointers.  That in 
itself would not be causing your error, though.

Try this:

    void TSpeech::SpeakToFile(const WideString &sWords, const WideString 
&sFileName)
    {
        HRESULT hr;
        CComPtr<ISpStream> cpStream;
        CComPtr<ISpVoice> cpVoice;
        CSpStreamFormat cAudioFmt;


        //Create a SAPI Voice
        hr = CoCreateInstance( CLSID_SpVoice, NULL, CLSCTX_LOCAL_SERVER, 
IID_ISpVoice, (void**)&cpVoice);

        //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(sFileName,  SPFM_CREATE_ALWAYS, &cpStream, 
&cAudioFmt.FormatId(), cAudioFmt.WaveFormatExPtr());
        }

        if( hr == E_INVALIDARG )
            MessageBox(NULL, "E_INVALIDARG", "Error", MB_OK);

        //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(sWords, SPF_DEFAULT, NULL);

        //close the stream
        if( SUCCEEDED(hr) )
            hr = cpStream->Close();
    }

> As for the compile errors, here they are (in German sorry):

There are plenty of online translators available ;-)

> [C++ Fehler] crtdbg.h(52): E2268 Aufruf der undefinierten Funktion '_T'

    Call of undefined function '_ T'

_T is a macro defined in tchar.h.  It operates the same as the TEXT() macro 
in winnt.h - it takes a character/string literal as input and compiles it as 
either char* or wchar_t* depending on whether UNICODE is defined.  Try 
including tchar.h in your source code before other the affected header 
files.

> [C++ Fehler] crtdbg.h(52): E2034 Konvertierung von 'int' nach 'const char 
> *' nicht m�glich

    Cannot convert 'int' to 'const char *'

That is pretty self-explanatory.  That particular line is calling wsprintf() 
using the TEXT() macro:

  ::wsprintf(msg, TEXT("%s failed - %s/%d"), expr, file, line);

That is probably just an issue with TEXT() not being defined before being 
used, or it is being re-defined somewhere else.

> [C++ Fehler] crtdbg.h(52): E2340 Keine �bereinstimmung des Typs beim 
> Parameter 2 ('const char *' erwartet, 'int' erhalten)

    Type mismatch in parameter 2 (expected 'const char *', got 'int')

That is a side-effect of the previous error.

> [C++ Fehler] SPDebug.h(337): E2303 Typname erwartet

    Typename expected

That particular line is trying to declare a variable of type _HFILE:

    _HFILE m_hfilePrev;

I don't see _HFILE begin defined in any header files I have, though.  So it 
makes sense for that to be reported as an unknown type.  You'll just have to 
define it manually in your code before including SPDebug.h until you can 
figure out where it is supposed to come from:

    #define _HFILE HANDLE

> [C++ Fehler] SPDebug.h(337): E2139 In Deklaration fehlt ;

    Declaration is missing ;

That is a side-effect of the previous error.

> [C++ Fehler] SPDebug.h(47): E2451 Undefiniertes Symbol 'm_hfilePrev'

    Undefined Symbol 'm_hfilePrev'

Another side-effect.  Since __HFILE is not defined anywhere, m_hfilePrev is 
not fully declared, either.

> [C++ Fehler] SPDebug.h(62): E2451 Undefiniertes Symbol '_CRT_WARN'
> [C++ Fehler] SPDebug.h(69): E2451 Undefiniertes Symbol '_CRT_WARN'
> [C++ Fehler] SPDebug.h(76): E2451 Undefiniertes Symbol '_CRT_WARN'
> [C++ Fehler] SPDebug.h(86): E2451 Undefiniertes Symbol '_CRT_ASSERT'
> [C++ Fehler] SPDebug.h(93): E2451 Undefiniertes Symbol '_CRT_WARN'
> [C++ Fehler] SPDebug.h(177): E2451 Undefiniertes Symbol 
> '_CRTDBG_MODE_DEBUG'
> [C++ Fehler] SPDebug.h(185): E2451 Undefiniertes Symbol 
> '_CRTDBG_MODE_WNDW'
> [C++ Fehler] SPDebug.h(298): E2451 Undefiniertes Symbol 
> '_CRTDBG_MODE_FILE'

Those are also not defined in any header files I have.  It looks like they 
are supposed to come from CRTDBG.H, but Borland appears to have edited that 
file for their own purposes.

> [C++ Fehler] SPDebug.h(297): E2268 Aufruf der undefinierten Funktion 
> '_CrtSetReportMode'

    Call of undefined function '_CrtSetReportMode'

Self-explanatory.  I believe that was also supposed to come from CRTDBG.H.

> [C++ Fehler] SPDebug.h(309): E2379 In Anweisung fehlt ;

    Instruction is missing ;

That is a side-effect of the previous error.

> [C++ Fehler] SPDebug.h(323): E2121 ) fehlt beim Funktionsaufruf

    ) is missing in function call

Another side effect.

> [C++ Fehler] SPDebug.h(371): E2268 Aufruf der undefinierten Funktion 
> '_RPT1'
> [C++ Fehler] sphelper.h(446): E2268 Aufruf der undefinierten Funktion 
> '_RPT3'

    Call of undefined function '_RPT1'
    Call of undefined function '_RPT3'

More macros missing from CRTDBG.H

> [C++ Fehler] sphelper.h(446): E2228 Zu viele Fehlermeldungen oder 
> Warnungen

    Too many error messages or warnings

Enough said.


Gambit 
Technical Details
Message-ID: <4744b412$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <47446f75$1@newsgroups.borland.com> <47449cae@newsgroups.borland.com> <4744a4e3$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,67677465280073fd
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <47446f75$1@newsgroups.borland.com> <47449cae@newsgroups.borland.com> <4744a4e3$1@newsgroups.borland.com>
Subject: Re: BCB and SAPI v5
Date: Wed, 21 Nov 2007 14:40:09 -0800
Lines: 178
Organization: Lebeau Software
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; Response
NNTP-Posting-Host: 207.178.157.90
Message-ID: <4744b412$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1195684882 207.178.157.90 (21 Nov 2007 14:41:22 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail