Set the argument to a function in order to process it
<p>So, I neet to set the argument to a function in order to convert it to a .mp3 file. Using this line : <code>$tts-&gt;setText($row['raspuns']);</code> doesn't happen anything but if i write <code>$tts-&gt;setText("Hello World!");</code> it works perfectly, which takes me to the conclusion that i have to find a correct code to make that tts get the text. Can anyone help me please?</p>

<pre><code>&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;
            Bot
        &lt;/title&gt;
        &lt;link type="text/css" rel="stylesheet" href="main.css" /&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;form action="bot.php "method="post"&gt;
            &lt;lable&gt;You:&lt;input type="text" name="intrebare"&gt;&lt;/lable&gt;
            &lt;input type="submit" name="introdu" value="Send"&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
&lt;?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("robo") or die(mysql_error());

$intrebare=$_POST['intrebare'];
$query = "SELECT * FROM dialog where intrebare = '$intrebare'"; 
$result = mysql_query($query) or die(mysql_error());
$row = $result;
?&gt;

&lt;?php
require "tts.php";
$tts = new TextToSpeech();
**$tts-&gt;setText($row['raspuns']);**
*//$tts-&gt;setText("Hello World!");*
$tts-&gt;saveToFile("voice.mp3");
$file='voice.mp3';
?&gt;

&lt;div id="history"&gt;
&lt;?php       

    while (true == ($row = mysql_fetch_array($result))) {
    echo "&lt;b&gt;The robot says: &lt;/b&gt;&lt;br /&gt;";
    echo $row['raspuns'];
    echo "&lt;embed src =\"$file\" hidden=\"true\" autostart=\"true\"&gt;&lt;/embed&gt;";
}
?&gt;
&lt;/div&gt;
</code></pre>

<p>Here's the tts.php file:</p>

<pre><code>&lt;?php
class TextToSpeech {
    public $mp3data;
    function __construct($text="") {
        $text = trim($text);
        if(!empty($text)) {
            $text = urlencode($text);
            $this-&gt;mp3data = file_get_contents("http://translate.google.com/translate_tts?tl=en&amp;q={$text}");
        }
    }

    function setText($text) {
        $text = trim($text);
        if(!empty($text)) {
            $text = urlencode($text);
            $this-&gt;mp3data = file_get_contents("http://translate.google.com/translate_tts?tl=en&amp;q={$text}");
            return  $this-&gt;mp3data;
        } else { return false; }
    }

    function saveToFile($filename) {
        $filename = trim($filename);
        if(!empty($filename)) {
            return file_put_contents($filename,$this-&gt;mp3data);
        } else { return false; }
    }
}
?&gt;
</code></pre>
