Page 1 of 1

Trouble using festival in PHP

Posted: Thu Jan 12, 2012 10:47 am
by martinfreefall
This is the code i used ..every thing is working except the EXCE part ...help pls

<?php
//create a random number filename so that simultaneous users don't overwrite each other
$filename = 'test.txt';
$text = 'This text will be converted to audio recording';
$outputfile = basename($filename, ".txt");
$outputfile = $outputfile . '.wav';

if (!$handle = fopen($filename, "w+"))
{
//we cannot open the file handle!
echo "Cannot open";
return false;
}
// Write $text to our opened file.
if (fwrite($handle, $text) === FALSE)
{
//couldn't write the file...Check permissions
echo "Cannot write";
return false;
}

fclose($handle);

//initialise and execute the festival C engine
//make sure that your environment is set to find the festival binaries!



exec("text2wave hello.txt -o hello1.wav");
$cmd = "text2wave $outputfile -o $filename ";
//execute the command
exec($cmd);

//unlink($filename);
echo "Recording is successful. \nRecording File: " . $outputfile;
//finally return the uptput file path and filename
return $outputfile;

?>

Re: Trouble using festival in PHP

Posted: Sat Jan 14, 2012 2:47 am
by Christopher
You need to be sure that the text2wave program is executable by the web server user. I also would recommend using absolute paths for $outputfile and $filename to directories that are readable/writable by the web server user.