To make it work outside of ExeOutput I changed to the directory “C:\Program Files (x86)\ExeOutput for PHP 2018\PHPRuntime72” and execute the following command "php.exe -d extension=ext\php_com_dotnet.dll -r "$voice=new COM('SAPI.SpVoice'); $voice->Speak('hello world');"
This method allows the program to run so that does seem to be an option. Thank you for your help.
Using the x86 version of the DLL from the plugins folder, I added that to the root dir of my project and set it to unpack the file upon startup.
In my UserMain script I added the following functions
function Uni_Voice_Init: Integer; stdcall; external "SAPI_UNITY_DLL.dll";
function Uni_Voice_Speak(TextToSpeech: String): Integer; stdcall; external "SAPI_UNITY_DLL.dll";
function Uni_Voice_Close: Integer; stdcall; external "SAPI_UNITY_DLL.dll";
procedure Speak(s: String);
begin
// when calling from javascript input is terminated at "/" character
// so replace them with "~" and they will be put back here
s := ReplaceString(s, "~", "/");
//MessageDlg(s, "The text", mtInformation, [mbOK]);
Uni_Voice_Speak(s);
end;
In the existing function OnPubLoaded I added
Uni_Voice_Init();
and in OnPubBeingClosed I added
Uni_Voice_Close();
Now from javascript, I can do
exeoutput.RunHEScriptCom('UserMain.Speak|This is <emph>some<~emph> text!');
Notice I replaced the < /emph> with <~emph>. Something was truncating the string at the ‘/’ character so I changed it to a ‘~’ character and replace it in the Speak function.