Skip to content

Instantly share code, notes, and snippets.

@cyc0der
Created July 22, 2015 05:17
Show Gist options
  • Save cyc0der/a22db7f199711db5c4f7 to your computer and use it in GitHub Desktop.
Save cyc0der/a22db7f199711db5c4f7 to your computer and use it in GitHub Desktop.
download word speech from google translate
<form method="post" action="">
word : <input type="text" name="word" value="hello" /> <br/>
folder : <input type="text" name="folder" value="word_speech" /> <br/>
<input type="submit" name="Download" value="Download" /> <br /> <br />
</form>
<?php
if(isset($_POST[Download])) {
$content = file_get_contents('http://translate.google.com/translate_tts?tl=en&q=' . urlencode($_POST['word']));
if(!$content) {
echo '<span style="color:#FF0000">Download Failed!</span><br>';
continue;
};
if(!file_put_contents($_POST[folder] . '/'. $_POST['word'] . '.mp3', $content)) {
echo '<span style="color:#FF0000">can't save mp3 file</span><br>';
continue;
};
echo '<span style="color:green">download success</span><br>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment