title: Text-to-speech in PHP with Google Translate
body: <p>I am trying to convert <strong>words</strong> to <strong>speech</strong> ..</p>
  
  <p>Untill now I have tried this: </p>
  
  <pre><code>&lt;?php
   $text = "Hello this is a test for voice api of google";
  
  // Name of the MP3 file generated using the MD5 hash
     $file  = md5($text);
  
  // Save the MP3 file in this folder with the .mp3 extension 
     $file = "audio/" . $file .".mp3";
     if($file) {
       echo "created";
     } else {
       echo "not created";
     }
  
  // If the MP3 file exists, do not create a new request
     if (!file_exists($file)) {
       $mp3 = file_get_contents(
          'http://translate.google.com/translate_tts?q=' . $text);
       echo "hello";
       file_put_contents($file, $mp3);
     } else {
       echo "hii";
     }
  ?&gt;
  </code></pre>
  
  <p>In my html file :</p>
  
  <pre><code>&lt;audio controls="controls" autoplay="autoplay"&gt;
    &lt;source src="&lt;?php echo $file; ?&gt;" type="audio/mp3" /&gt;
  &lt;/audio&gt;
  </code></pre>
  
  <p>I am getting created hello and an audio player in output. But no file is played and neither it is created in the folder?</p>