Created
December 30, 2019 09:24
-
-
Save giangmd/1f465dbacbcca1e65b08e40ae5fcf772 to your computer and use it in GitHub Desktop.
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
<?php | |
$text = "Xin chào tất cả mọi người. Tôi tên là Giang. Hôm nay, tôi đến đây để làm việc. Chúc mọi người làm việc vui vẻ!"; | |
$lang = "vi"; | |
$file = md5($lang."?".urlencode($text)); | |
$file = "audio/" . $file . ".mp3"; | |
if (!is_dir("audio/")) | |
mkdir("audio/"); | |
else | |
if (substr(sprintf('%o', fileperms('audio/')), -4) != "0777") | |
chmod("audio/", 0777); | |
if (!file_exists($file)) | |
{ | |
$mp3 = file_get_contents('https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q='. urlencode($text) .'&tl='. $lang .'&total=1&idx=0&textlen=5&prev=input'); | |
file_put_contents($file, $mp3); | |
} | |
die; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment