Google TTS API for Arabic, Chinese and Greek

╄→гoц情女王★ 提交于 2019-11-30 15:39:51

Use the path as a URI rather than a string then change it to an ascii string.

URI uri = new URI("http://translate.google.com/translate_tts?tl=zh-TW&q=你好");

URL u = new URL(uri.toASCIIString());

I have your same problem. But I have solve it yesterday. I wanna the API say Chinese and save to mp3 file .

The url now is: path ="http://translate.google.com/translate_tts?tl=zh-TW&q=你好" you do as follow: path ="http://translate.google.com/translate_tts?ie=UTF-8&tl=zh-TW&q=".urlencode("你好");

Add a param ie=utf-8 AND encode the Chinese words. You'll got what you want .

and if the app crashes try this

txtToTranslate = txtToTranslate.replace(" ", "%20");

it replaces the spaces between the words.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!