Created
July 22, 2015 05:17
-
-
Save cyc0der/a22db7f199711db5c4f7 to your computer and use it in GitHub Desktop.
download word speech from google translate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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