3 * Festival Wrapper class for the Festival Text To Speech Synthesis System
4 * @link http://www.ctsr.ed.ac.uk/projects/festival/
5 * @author Paul Scott (base design) + Roman Bazalevskiy (adaptation for multilingual+server environment)
13 * Method to wrap API calls to the festival tts engine
14 * This function will create an utterance and output it to $outputfile. '.wav';
15 * @author Paul Scott (base design) + Roman Bazalevskiy (adaptation for multilingual+server environment+no temp files!)
19 function text2Wav($string,$lang = "ru")
22 $prolog="/etc/festival/$lang.scm";
23 if (!file_exists($prolog)) {
24 $prolog="/etc/festival/default.scm";
27 //make sure that your environment is set to find the festival binaries!
28 $cmd = "festival_client --prolog $prolog --ttw | lame -f - -";
30 $descriptorspec = array(
31 0 => array("pipe", "r"), // stdin is a pipe that the child will read from
32 1 => array("pipe", "w"), // stdout is a pipe that the child will write to
33 2 => array("pipe", "w") // stderr is a file to write to
37 $process = proc_open($cmd, $descriptorspec, $pipes, $cwd, $env);
38 if (is_resource($process)) {
39 fwrite($pipes[0],$string);
41 $data = stream_get_contents($pipes[1]);
44 $proc_result = proc_close($process);