How to use the google TTS engine in freepbx?

Hi,

I’m actually playing around with these TTS engines.
Flite sounds horrible, so I was looking for cheap alternatives.
Unfortunately I could only find google TTS. There is also a agi script for google-tts but I have no idea how to implement it.

Is there anyone who can help?

THX
mts

I just solved it myself:
I modified this file: propolys-tts.agi like this:

switch ($engine) {
case ‘text2wave’:
exec($enginebin." -f 8000 -o $wavefile $voice $textfile");
break;
case ‘flite’:
exec($enginebin." -f $textfile -o $wavefile");
break;
case ‘swift’:
exec($enginebin." -p audio/channels=1,audio/sampling-rate=8000 -o $wavefile -f $textfile");
break;
case ‘googleTTS’:
exec($enginebin." -l de -f $textfile -r 8000 -o $wavefile");
break;
default:
}

I just copied “googletts-cli.pl” to some directory and added googleTTS as tts-engine.

Maybe someone can use it one day.
CU

hi, can you explain better how you modifiy the file and where you put the google files?
in particular what is the exact point in propolys-tts where you add your code?

thanks

You will find the file under: ./var/lib/asterisk/agi-bin/propolys-tts.agi
here is a larger snipset of the code:if ( !file_exists($wavefile) ) {
debug(“Text to speech wave file doesnt exist, lets create it.”, 1);
if ( false === ($fh = fopen($textfile, “w”)) ) {
debug(“ERROR: Cannot open the file: $textfile”, 1);
return 1;
}
if ( false === fwrite($fh, $text) ) {
debug(“ERROR: Cannot write to file: $textfile”, 1);
return 1;
}
fclose($fh);
debug(“Executing $engine”, 1);
switch ($engine) {
case ‘text2wave’:
exec($enginebin." -f 8000 -o $wavefile $voice $textfile");
break;
case ‘flite’:
exec($enginebin." -f $textfile -o $wavefile");
break;
case ‘swift’:
exec($enginebin." -p audio/channels=1,audio/sampling-rate=8000 -o $wavefile -f $textfile");
break;
case ‘googleTTS’:
exec($enginebin." -l de -f $textfile -r 8000 -o $wavefile");
break;
default:
}
}

You can copy the googletts-cli.pl file to any directory you like.

  1. Use the freepbx webinterface and go to ->Settings->Text To Speech Engines
  2. Create a new Engine and call it googleTTS (or the name you gave it above)
  3. Set the engine-path to your googletts file (e.g. /usr/bin/googleTTS/googletts-cli.pl)
    Thats it.

Just one more thing.
-> exec($enginebin." -l de -f $textfile -r 8000 -o $wavefile");

“-l de” is the language. If you need english (en) or any other language just modify it.

hi,
i did everything then i create a text to speech item. when i call the asterisk answers and then hangup after 1 second.
if i check under /var/lib/asterisk/sounds/tts i found a txt with the text inserted in the “text to speech” menu but no wav file.

Try running the script manually to see if it’s working.
Have a look at the /var/log/asterisk/full
It will probably not find the script.

i launched the script and it gives some errors of missing perl modules.
i installed it. and now it works!
thanks a lot

i discover that is mandatory to write the text in “text to speech” module without give enters between phrases.
on the contrary the script will not work.

User mts, note that any future upgrades to the Text to Speech module will probably overwrite the file, “/var/lib/asterisk/agi-bin/propolys-tts.agi” make sure to keep a backup of your changes.

Are there any devs watching this thread? This is the first time I have seen a method to use googletts with native FreePBX TTS modules, and it is not pretty. From my reading of the code in “agi-bin/propolys-tts.agi”, it looks like the native FreePBX TTS and TTS Engines modules only support 3 projects, text2wave, flite and swift, and to use any other TTS project requires a hack as detailed above.

I have to agree with lgaetz. This method isn’t very nice.
It would be great to extend the TTS possibilities of freepbx.

As a temporary solution, it would be great to integrate google to the default TTS-engines. In my opinion google tts has by far the best free TTS-engine.