Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am making a language learning web app that when you hover over the word, it pronounces it for you. I'd like to access the native speaker translations from Google Translate API.

I've found this resource which gives http://translate.google.com/translate_tts as the base URL and tl for target language and q for the query string.

This works awesome when I just access it in the browser, http://translate.google.com/translate_tts?tl=zh-CN&q=你好, but any httprequests for my app return a 403 Forbidden error.

localhost:~ me$ wget "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=hello+world" --2015-06-02 11:02:06-- http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=hello+world Resolving translate.google.com... 173.194.123.38, 173.194.123.36, 173.194.123.32, ... Connecting to translate.google.com|173.194.123.38|:80... connected. HTTP request sent, awaiting response... 403 Forbidden 2015-06-02 11:02:07 ERROR 403: Forbidden.

Is there a formal Google API for text-to-speech associated with their payment plans for traditional Google Translate API that I'm just not finding? Or is there a way to get and play this audio somehow?

like image 287
user3871 Avatar asked Jun 02 '15 15:06

user3871


People also ask

Does Google Translate API have a limit?

Google Translate API also has a default limit of 2 million characters per day and 100,000 characters per 100 second. The former can be increased up to 50 million characters per day.

Can I use Google Translate API for free?

The Google Translate API is not free. Its pricing is based off monthly usage in terms of millions of characters. It costs $20 per 1 million characters for translation or language detection. Price is per character sent to the API for processing, including whitespace characters.

Is Google Translate deprecated?

Google Translate is still available for very narrow purposes and use cases. Specifically, to quote Google's official resource: [The website widget can be used by] government, non-profit, and/or non-commercial websites (for example, academic institutions) that focus on COVID-19 response.


2 Answers

You can get anything sound, I found it: https://translate.google.com.vn/translate_tts?ie=UTF-8&q=ANYTHING_TEXT&tl=en&client=tw-ob Note: client=tw-ob

like image 200
Tan Nguyen Avatar answered Sep 19 '22 02:09

Tan Nguyen


That resource is dated. Google deprecated free access to the language translate api. Now an API key is needed. The api is also now in V2.

Without an api key you will receive the 403 forbidden error.

More information here: https://cloud.google.com/translate/docs

like image 21
Tarang Avatar answered Sep 21 '22 02:09

Tarang