Article View: borland.public.cppbuilder.nativeapi
Article #1065Re: Startup help with SAPI
From: Marc
Date: Sat, 17 Nov 2007 13:57
Date: Sat, 17 Nov 2007 13:57
91 lines
3617 bytes
3617 bytes
Thanks!
"JohnC" <jcibulskis@sbcglobal.net> schrieb im Newsbeitrag
news:473ee927$1@newsgroups.borland.com...
> The following will "speak" anything - numbers as well as words.
> John
> //---------------------------------------------------------------------------
>
> #ifndef JMCSpeechH
> #define JMCSpeechH
>
> #include <sapi.h> //For ISp definitions - part of SDK
>
> //---------------------------------------------------------------------------
>
> //Speech Utilities:
> //This object instantiates the COM Object SpVoice and gives us an easy
> //function call in order to speak a string.
>
> class TJMCSpeech
> {
> public:
> TJMCSpeech(); //Constructor
> ~TJMCSpeech(); //Destructor
> void Speak(String Words); //Speak the input words in the string.
> private:
> HRESULT hr;
> ISpVoice* pVoice;
> };
>
>
> #endif
> -------------------
> //---------------------------------------------------------------------------
> #include <vcl.h>
> #pragma hdrstop
>
> #include "JMCSpeech.h"
> //#include "SUTIL.h"
> //---------------------------------------------------------------------------
>
> #pragma package(smart_init)
>
> //Constructor
> TJMCSpeech::TJMCSpeech()
> {
> hr = S_OK;
> pVoice = NULL;
> ::CoInitialize(NULL);
>
> //Create a SAPI voice:
> hr = CoCreateInstance( CLSID_SpVoice,NULL,CLSCTX_ALL,IID_ISpVoice,
> (void**)&pVoice);
> }
> //Destructor
> TJMCSpeech::~TJMCSpeech()
> {
> if(SUCCEEDED(hr))
> pVoice->Release();
>
> ::CoUninitialize();
> }
> //---------------------------------------------------------------------------
> void TJMCSpeech::Speak(String Words)
> {
> if(SUCCEEDED(hr))
> pVoice->Speak(WideString(Words),SPF_DEFAULT,NULL);
> }
> //Note: I originally had:
> // pVoice->Speak(TJMCSUtil::StrToBSTR(Words),SPF_DEFAULT,NULL);
> //It was pointed out by Remy Lebeau (TeamB) <no.spam@no.spam.com>
> //that this was a memory leak and that I should use the following:
> // pVoice->Speak(WideString(Words),SPF_DEFAULT,NULL);
> //---------------------------------------------------------------------------
>
>
> "Marc" <info@mawnet.com> wrote in message
> news:473ebe39$1@newsgroups.borland.com...
>> Hi all
>>
>> I try to implement a simple SAPI application that reads back a phone
>> number. I downloaded the SDK 5.1 from Microsoft and had a look at the
>> samples... and did not quite got into it. Does someone has a simple
>> sample in BCB that just shows how to speak a number?
>>
>> Rds
>> Marc
>>
>
>
Technical Details
Message-ID:
<473ef38a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder6.cambrium.nl!feed.tweaknews.nl!xlned.com!feeder1.xlned.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<473ebe39$1@newsgroups.borland.com> <473ee927$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ead936854bc3aa40 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 References: <473ebe39$1@newsgroups.borland.com> <473ee927$1@newsgroups.borland.com> Subject: Re: Startup help with SAPI Date: Sat, 17 Nov 2007 14:57:35 +0100 Lines: 93 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: 83.77.49.247 Message-ID: <473ef38a$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1195307914 83.77.49.247 (17 Nov 2007 05:58:34 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feeder6.cambrium.nl!feed.tweaknews.nl!xlned.com!feeder1.xlned.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail