Skip to content

Instantly share code, notes, and snippets.

@alotaiba
Created February 3, 2012 07:31
Star You must be signed in to star a gist
Save alotaiba/1728771 to your computer and use it in GitHub Desktop.
Google Text to Speech API

Google Text to Speech API

Base URL: http://translate.google.com/translate_tts
It converts written words into audio. It accepts GET requests.

GET

q
The query string to convert to audio

tl
Translation language, for example, ar for Arabic, or en-us for English

ie
Encoding format, use default UTF-8

Examples

This is an example for Arabic "السلام عليكم"

http://translate.google.com/translate_tts?ie=UTF-8&q=%D8%A7%D9%84%D8%B3%D9%84%D8%A7%D9%85%20%D8%B9%D9%84%D9%8A%D9%83%D9%85&tl=ar

This is an example for English "Hello World"

http://translate.google.com/translate_tts?ie=UTF-8&q=Hello%20World&tl=en-us
@HealingTek
Copy link

Sometime recently I exceeded some undocumented limit and no longer get anything via CLI. If I enter the URL into a browser I get sent to a captcha, after which it works. Anybody seen this and have a suggestion of how to proceed?

@shdown
Copy link

shdown commented Aug 27, 2015

@HealingTek, append &client=t to your URL and make sure your CLI client has a browser User-Agent string (e.g. Mozilla/5.0 (X11; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0) (see https://gist.github.com/alotaiba/1728771#gistcomment-1546762).

@zulhfreelancer
Copy link

This is cool!

@iiiears
Copy link

iiiears commented Sep 28, 2015

Great! The world is now smaller and friendlier. :)

@GokulaKrishnanOoty
Copy link

Hi Guys ,
I am ok taking a paid service, but tis there a way i can change the voice, I may possibly need a male voice and with different accents . Does the API has this service ?

@markelsoft
Copy link

All this works appending to avoid seeing the captcha: Mozilla/5.0 and &client=t. However, Google will still throttle use of the API if it notices "unusual activity" from a client IP. I tried it and sometimes would work and sometimes would not as Google would throttle/disable from the client url. If there any way around this?

@eteache
Copy link

eteache commented Feb 29, 2016

Today this is not working anymore.

@oaeide
Copy link

oaeide commented Mar 13, 2016

@krist-jin
Copy link

Thanks @oaeide it works for me (obviously the example in the md article is no longer valid...)
It's quite a confusion for me that why Google does not provide a clear doc for this API about each argument? It's disappointed that we have to guess how to use it properly...

@MarcoBuster
Copy link

I have error 403.
Negated access. How I can fix it?

@rcarubbi
Copy link

I´ve made a helper to .net... check it out in my git hub... but to play in your app you'll need add references from windows media player.

@gabouh
Copy link

gabouh commented May 10, 2016

Thanks @oaeide it works for me. 👍

How it would be possible to have that service offline?, the input text to an mp3 file ?

@Vitorspk
Copy link

Thanks you @oaeide it works for me too.

@SeyedAliKia
Copy link

How to use this api for persian language ?

Copy link

ghost commented Aug 7, 2016

Thanks @oaeide it works for me too.

@albovieira
Copy link

@Qutyba
Copy link

Qutyba commented Oct 13, 2016

Thanks @oaeide it works for me

@Smile4ever
Copy link

You need to add &client=tw-ob to make it work.

http://translate.google.com/translate_tts?tl=en&q=addressed&client=tw-ob

@azim91
Copy link

azim91 commented Feb 3, 2017

hi, i dont use it in android device, how can fix it ?

@hmdnprks
Copy link

Thank you @rcarubbi for providing .NET helper class

@acrolink
Copy link

The code with wget works fine. Does anyone know how to force male voice instead of female? Thank you.

@Nalinh
Copy link

Nalinh commented Mar 28, 2017

How to use this api for Vietnamese language ? Plz ! Tks

@Nalinh
Copy link

Nalinh commented Mar 28, 2017

@hungnmai
Copy link

Thanks @Smile4ever

@Bald-Badger
Copy link

It now returns a 503 ERROR

@cathhriss
Copy link

@hirahassanawan
Copy link

i got 404 error. Although I'm just using hardly 10 characters. still it is not working.

@naghamsayegh
Copy link

I'm trying to get text-speech into my react app ,I've found this example [https://codesandbox.io/s/1ggs6] ,it worked fine with chrome and edge,otherwise on Firefox it can't read more than 2 languages US-english ,I just want the german language.
Any idea on how to fix it ?

@TheVisionariesInk
Copy link

tl=en
If it is not lowercase it fails for me

@momokrunic
Copy link

I created a Python package for this purpose. You can find it here:
https://gitlab.com/labsoft-ai/google-translate-tts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment