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: {$mode objfpc} Program Zira; Uses SysUtils, Classes, Process; Procedure Zira(ZiraZtring: AnsiString); Var ScriptText: TStringList; Process: TProcess; Begin ScriptText := TStringList.Create; ScriptText.Add('Set objVoice = CreateObject("SAPI.SpVoice")'); ScriptText.Add('Set objVoice.Voice = objVoice.GetVoices().Item(1)'); ScriptText.Add('objVoice.Speak "' + ZiraZtring + '"'); ScriptText.SaveToFile('ZiraScript.vbs'); Process := TProcess.Create(nil); Process.Executable := 'WScript.exe'; Process.Parameters.Add('ZiraScript.vbs'); Process.Execute; Process.WaitOnExit; ScriptText.Free; DeleteFile('ZiraScript.vbs'); End; Begin Zira('Hello World'); End.
From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of Rafael Picanço via fpc-pascal Sent: Sunday, June 25, 2023 2:17 PM To: fpc-pascal@lists.freepascal.org Cc: Rafael Picanço <cpicanc...@gmail.com> Subject: Re: [fpc-pascal] Microsoft SAPI on Freepascal Hi James, 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? https://stackoverflow.com/questions/17970573/using-word-ole-in-lazarus-freepascal Best, R
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal