Hi,

Can anyone tell me how to convert text to speech in PHP? There are some tools like festival and flite etc that can be used for converting text to speech. But i don't have much expertise in PHP.

You can use festival TTS program for converting text to voice (text to speech) in PHP. Following code is taken from here

<?php
$filename = 'test.txt';
$text = 'This text will be converted to audio recording';
$outputfile = basename($filename, ".txt");
$outputfile = $outputfile . '.wav'; 
if (!$handle = fopen($filename, "w"))
{
    return false;
}
if (fwrite($handle, $text) === FALSE)
{
    return false;
} 
fclose($handle); 
//initialise and execute the festival C engine
//make sure that your environment is set to find the festival binaries!
$cmd = "text2wave $filename -o $outputfile";
//execute the command
exec($cmd); 
unlink($filename);
echo "Recording is successful. \nRecording File: " . $outputfile;
return $outputfile; 
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.