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)
19 function text2Wav($string,$lang = "ru")
21 //create a random number filename so that simultaneous users don't overwrite each other
22 $tempfilename = tempnam('/tmp','fest-');
23 $filename = $tempfilename . '.txt';
24 $outputfile = $tempfilename . '.wav';
26 if (!$handle = fopen($filename, "w"))
28 //we cannot open the file handle!
31 // Write $string to our opened file.
32 if (fwrite($handle, $string) === FALSE)
34 //couldn't write the file...Check permissions
37 //close the file handle - we are done with it
40 $prolog="/etc/festival/$lang.scm";
41 if (!file_exists($prolog)) {
42 $prolog="/etc/festival/default.scm";
45 //initialise and execute the festival C engine
46 //make sure that your environment is set to find the festival binaries!
47 $cmd = "festival_client --prolog $prolog --ttw $filename --output $outputfile";
51 //delete the text file (Temp)
53 //finally return the uptput file path and filename