Home > Backend Development > PHP Tutorial > PHP calls Google translate_tts api implementation code_PHP tutorial

PHP calls Google translate_tts api implementation code_PHP tutorial

WBOY
Release: 2016-07-21 14:59:29
Original
1519 people have browsed it

When I used Google Translate today, I found a good thing: Google translate_tts. You can hear the English pronunciation by calling this API,
saving you the trouble of uploading audio files yourself.
I wrote a calling method using PHP to save audio files locally.
is as follows:

Copy the code The code is as follows:

$newfname = '1.wmv ';
$reqBaseURL = 'http://translate.google.com/translate_tts?tl=en&q=how%20do%20you%20do';
$remote_file = fopen($reqBaseURL, "rb");
if ($remote_file){
$newf = fopen($newfname, "wb");
if ($newf){
while(!feof($remote_file)){
fwrite($newf, fread($remote_file, 1024 * 8),1024 * 8);
}
}
}
if ($remote_file) {
fclose($remote_file);
}
if ($newf) {
fclose($newf);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/328136.htmlTechArticleWhen I used Google Translate today, I found a good thing: Google translate_tts. You can hear the English pronunciation by calling this API. Save yourself the trouble of uploading audio files yourself. I wrote a tune in php...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template