如何在php中对Google translate_tts api进行调用

如何在php中对Google translate_tts api进行调用?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

代码如下:


$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);
}

看完上述内容,你们掌握如何在php中对Google translate_tts api进行调用的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!