Google Translate API - No Access Control Origin with Text to Speech

≡放荡痞女 提交于 2019-12-18 08:55:29

问题


I posted this question on SO to get Google Translate Text-To-Speech to work.

Google Translate API text-to-speech: http requests forbidden

I was told I needed a key and to enable billing. I've since done that. I know billing is enabled because, using their specified endpoint for words-only translations (not narrated speech) (GET https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY&source=en&target=de&q=Hello%20world), I'm able to get a response both in DHC and in my application $.get:

In my original question (above), I was told If I get an API key, I would no longer be blocked from getting text-to-speech. I tested the request for Text-to-speech in DHC and Postman:

https://translate.google.com/translate_tts?key=myKeyHere&ie=utf-8&tl=zh-CN&q=你好

And got a 200:

Excellent. However, in my application, I make a get request:

    $.get('https://translate.google.com/translate_tts?key='+myKey+'&ie=utf-8&tl=en&q=Hello+world',
        function (returned_data) {

I get blocked:

No 'Access-Control-Allow-Origin' header

Why is this?

来源:https://stackoverflow.com/questions/30929518/google-translate-api-no-access-control-origin-with-text-to-speech

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