Text to voice conversion. To convert text to voice I have used Google TTS (Text to Speech) it will create an mp3 file and play it its a very simple script you must try its written in PHP it can convert almost 50+ languages. This Class converts text to speech using Google text to speech API to transform text to mp3 file which will be downloaded and later used as eg. embed file.
<?php
include 'PHP_Text2Speech.class.php';
$t2s = new PHP_Text2Speech;
?>
<audio controls="controls" autoplay="autoplay">
<source src="<?php echo $t2s->speak("Hello PHPGang");?>" type="audio/mp3" />
</audio>
Calling Google url to get mp3 file.
if (!file_exists($this->mp3File)) {
$this->download("http://translate.google.com/translate_tts?ie=UTF-8&q={$this->text}&tl={$this->lang}&total={$this->wordCount}&idx=0&textlen={$this->textLen}", $this->mp3File);
}