[fpc-pascal] Microsoft SAPI on Freepascal
tsiegel at softcon.com
tsiegel at softcon.com
Tue Jun 27 01:29:32 CEST 2023
Also, for what it's worth, your code works fine on fpc 3.20.
On 6/26/2023 11:04 PM, James Richters via fpc-pascal wrote:
> I appreciate the help with this. I'm still confused.
> In my original post, I already had CoInitialize, CoUninitialize; and Unit
> ComOBJ, Unit Windows and Unit ActiveX I was still getting EOleError:
> Variant does not reference an automation object.
>
> Do I need to do all this Change FPU stuff?
>
> I'm sure I'm doing something wrong but I still can't get it to work. Here's
> my original program. I wasn't even trying to change the voice yet. What do
> I need to do to this to make it work?
>
> James
>
> {$mode objfpc}
>
> uses
> CRT, Windows, SysUtils, ComObj, Variants, OLEServer, Classes, ActiveX,
> ShellApi;
>
> var
> SavedCW: Word;
> SpVoice: Variant;
> MyWideString: WideString;
> begin
> CoInitialize(nil);
> SpVoice := CreateOleObject('SAPI.SpVoice');
> MyWideString := WideString('Hello, the time is ' + TimeToStr(Now));
> Writeln(MyWideString);
> // Change FPU interrupt mask to avoid SIGFPE exceptions
> SavedCW := Get8087CW;
> try
> Set8087CW(SavedCW or $4);
> SpVoice.Speak(MyWideString, 0);
> finally
> // Restore FPU mask
> Set8087CW(SavedCW);
> end;
> Writeln('Press Any Key');
> ReadKey;
> CoUninitialize;
> end.
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
More information about the fpc-pascal
mailing list