Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Google Text to Speech API

Google Text to Speech API

Base URL:
It converts written words into audio. It accepts GET requests.


The query string to convert to audio

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

Encoding format, use default UTF-8


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

This is an example for English "Hello World"

Google now requires an API Key to use Google Translate on your website and charges $20 USD per million characters. Question: Where do you add the key within the above URL in order not to get a 404 message from Google.

Clear the referer header to avoid the 404.

Bashar commented Apr 19, 2014

@serapismurillo it works on smaller text (less than 100 chars i believe) anyhow for paid services do you think if its possible to extract the audio file such as .wav or .mp3 even on paid service?

Bashar commented Apr 19, 2014

Managed to get a way as follows:

wget -q -U Mozilla -O output.mp3 ""

TTS for Indian Language Hindi Word 'Namaste' converted to speech


imashok commented Oct 21, 2014

Anyone knows hot to use API key for this one. Because i am using this TTS in one of my app .And it is often getting blocked. I'm also unable to use more that 100 characters.

Is there any possibility of multiple voices..? Like male and female

how do i know if the language is supported ?

shdown commented Aug 9, 2015

Since recently, this service rejects (redirects to a captcha page) requests that either:

  1. have a non-browser User-Agent, including Mozilla/5.0;
  2. do not contain client=t.


How can I increase the limits of word to read at a time? Right now I think it is 100 words reading at a single request.

shdown commented Aug 11, 2015


How can I increase the limits of word to read at a time? Right now I think it is 100 words reading at a single request.

It's 100 characters IIRC. And the answer is — nohow. Consider sending multiple requests and then gluing them together.

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 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

This is cool!

iiiears commented Sep 28, 2015

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

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 ?

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 commented Feb 29, 2016

Today this is not working anymore.

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...

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

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 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 ?

Thanks you @oaeide it works for me too.

How to use this api for persian language ?


ghost commented Aug 7, 2016

Thanks @oaeide it works for me too.

Qutyba commented Oct 13, 2016

Thanks @oaeide it works for me

azim91 commented Feb 3, 2017

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

Thank you @rcarubbi for providing .NET helper class

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

Nalinh commented Mar 28, 2017

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

It now returns a 503 ERROR

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