[fpc-pascal] Microsoft SAPI on Freepascal
james.richters at productionautomation.net
Sun Jun 25 22:46:22 CEST 2023
I gave up on doing it directly, it seems SO convoluted to do with FPC with the COM unit and all this stuff I just don’t understand,
and it’s SO simple to do with a VBS script in just 3 lines and it just works! (it would only be 2 lines if I didn’t want Microsoft Zira)
So I decided to do this in the most ridiculous way possible.. but after 3 days of trying to get send something directly to SAPI with FPC ,
I’m done with it, and getting this to work was super easy.
Computers are fast enough that I don’t need to waste my time tying to figure this out, just have FPC write out a VBS script, and run it with Process.Execute problem solved!
Here it is, maybe it will help someone else struggling to get something so simple to work:
SysUtils, Classes, Process;
Procedure Zira(ZiraZtring: AnsiString);
ScriptText := TStringList.Create;
ScriptText.Add('Set objVoice = CreateObject("SAPI.SpVoice")');
ScriptText.Add('Set objVoice.Voice = objVoice.GetVoices().Item(1)');
ScriptText.Add('objVoice.Speak "' + ZiraZtring + '"');
Process := TProcess.Create(nil);
Process.Executable := 'WScript.exe';
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> On Behalf Of Rafael Picanço via fpc-pascal
Sent: Sunday, June 25, 2023 2:17 PM
To: fpc-pascal at lists.freepascal.org
Cc: Rafael Picanço <cpicanco42 at gmail.com>
Subject: Re: [fpc-pascal] Microsoft SAPI on Freepascal
I am not familiar with variants and Ole objects, sorry about that. I found some people using code with Ole objects and it that seems to work, can you chack if it applies to your case?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-pascal