Undefined variable error TTS PHP script
<p>I'm trying to make this code work but it won't. Somebody help me please. This is the first file, tts.php:</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 $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>

<p>Second file, index.php:</p>

<pre><code>&lt;?php
require "tts.php";
$tts = new TextToSpeech();
$tts-&gt;setText("Hello World!");
$tts-&gt;saveToFile("voice.mp3");
?&gt;
</code></pre>

<p>And this is the error: <img src="http://i.stack.imgur.com/yF9zT.png" alt="The error"></p>

<p>*I'm running the code on localhost</p>
