源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

php调用Google translate_tts api实现代码

  • 时间:2020-01-03 13:47 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:php调用Google translate_tts api实现代码
今天用google翻译时,发现个好东西:Google translate_tts,调用这个api就可以听到英文发音, 省掉了自己上传音频文件的麻烦。 我用php写了个调用的方法,可以把音频文件保存在本地。 [b]如下: [/b]
[u]复制代码[/u] 代码如下:
$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); }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部