tags:

views:

28

answers:

1

Hi, i own a translation service and now im wanting to implement a TTS solution. Do you know any software that can be executed from php to generate mp3s on the fly for a specific text?

+1  A: 

If you are in an environment where you can make system calls, you could pipe the output of Festival into lame like so:

<?php
$infile = tempnam();
file_put_contents($input, 'My name is judge');

$outfile = "/path/to/output.mp3";
$cmd = "text2wave -f 22050 < {$infile} | lame --quiet --preset medium  - {$outfile}";

$output = $status = null;
exec($cmd, $output, $status);

If you want to do further processing as well as the conversion, you can pipe the output of text2wave to SoX instead, which can also do the conversion for you:

text2wave -f 22050 < input.txt | sox - output.mp3

The default Festival voice seems to be a bit pants though, so this article might be worth investigating, but I haven't actually tried it myself.

I know you aren't using ubuntu but for others who might find this answer helpful, there is a problem where even after you install all the "ugly" plugins, SoX still cannot output MP3 files. You have to manually dismantle the .deb and modify the debian/rules file to remove --without-lame from DEB_CONFIGURE_EXTRA_FLAGS.

Shabbyrobe