Trouble using festival in PHP
Posted: Thu Jan 12, 2012 10:47 am
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;
?>
<?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;
?>