Text to Speech Options

Trying several options to put text to speech in my exeoutput 2018 app using php 7.2.

I wanted to use the HTML5 Speech API, but it appears that CEF doesn’t support the Speech API without API keys, etc.

I tried compiling in the php_com_dotnet.dll extension and using

$voice = new COM(SAPI.SpVoice);
$voice->Speak("I like iced tea");

and while it works outside of ExeOutput, it throws an “unknown exception” in ExeOutput.

I found a little app called voice.exe that I tried to compile into the program and execute with

$path = exo_unpackvirtualfile('voice.exe', '');
echo $path;
echo exec($path . " \"I liked iced tea\"");

But nothing seems to be happening when that supposedly executes.

Does anyone have a working solution for text to speech in a ExeOutput application?

Tested the code outside ExeOutput and in a normal PHP environment. The same error occurs when Speak is invoked.

exec() isn’t able to run virtual EXE files.
You must follow the tutorial here:
“Run a program that was compiled in the application”

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.

For anyone wanting the voice.exe file I found it here https://www.elifulkerson.com/projects/commandline-text-to-speech.php

As a follow up here is the method I ended up using. The voice.exe method works, but there was a small lag whenever the voice.exe had to be launched.

I downloaded a free to use speech wrapper DLL from https://forum.unity.com/threads/text-to-speech-dll-for-windows-desktop.56038/page-4#post-3340957.

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);          
    // 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]);  

In the existing function OnPubLoaded I added


and in OnPubBeingClosed I added


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.