Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@serapismurillo

This comment has been minimized.

Show comment
Hide comment
@serapismurillo

serapismurillo Aug 13, 2013

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.

serapismurillo commented Aug 13, 2013

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.

@richkettle

This comment has been minimized.

Show comment
Hide comment
@richkettle

richkettle commented Aug 15, 2013

@manuelpaulo

This comment has been minimized.

Show comment
Hide comment
@manuelpaulo

manuelpaulo Jan 16, 2014

Clear the referer header to avoid the 404.

manuelpaulo commented Jan 16, 2014

Clear the referer header to avoid the 404.

@Bashar

This comment has been minimized.

Show comment
Hide comment
@Bashar

Bashar 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

@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

This comment has been minimized.

Show comment
Hide comment
@Bashar

Bashar Apr 19, 2014

Managed to get a way as follows:

wget -q -U Mozilla -O output.mp3 "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=hello+world"

Bashar commented Apr 19, 2014

Managed to get a way as follows:

wget -q -U Mozilla -O output.mp3 "http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q=hello+world"
@GuruOnNet

This comment has been minimized.

Show comment
Hide comment
@GuruOnNet

GuruOnNet Jul 2, 2014

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

http://translate.google.com/translate_tts?tl=hi&q=%E0%A4%A8%E0%A4%AE%E0%A4%B8%E0%A5%8D%E0%A4%A4%E0%A5%87

OR

http://translate.google.com/translate_tts?tl=hi&q=नमस्ते

GuruOnNet commented Jul 2, 2014

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

http://translate.google.com/translate_tts?tl=hi&q=%E0%A4%A8%E0%A4%AE%E0%A4%B8%E0%A5%8D%E0%A4%A4%E0%A5%87

OR

http://translate.google.com/translate_tts?tl=hi&q=नमस्ते
@imashok

This comment has been minimized.

Show comment
Hide comment
@imashok

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

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.

@ningappa

This comment has been minimized.

Show comment
Hide comment
@ningappa

ningappa Apr 10, 2015

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

ningappa commented Apr 10, 2015

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

@MaxToyberman

This comment has been minimized.

Show comment
Hide comment
@MaxToyberman

MaxToyberman Jul 22, 2015

how do i know if the language is supported ?

MaxToyberman commented Jul 22, 2015

how do i know if the language is supported ?

@shdown

This comment has been minimized.

Show comment
Hide comment
@shdown

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

@MaxToyberman:
https://github.com/shdown/gt/wiki/Languages

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.

@MaxToyberman:
https://github.com/shdown/gt/wiki/Languages

@tapastalukder

This comment has been minimized.

Show comment
Hide comment
@tapastalukder

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

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

@shdown

This comment has been minimized.

Show comment
Hide comment
@shdown

shdown Aug 11, 2015

@tapastalukder:

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.

shdown commented Aug 11, 2015

@tapastalukder:

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.

@HealingTek

This comment has been minimized.

Show comment
Hide comment
@HealingTek

HealingTek Aug 24, 2015

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?

HealingTek commented Aug 24, 2015

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

This comment has been minimized.

Show comment
Hide comment
@shdown

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

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

This comment has been minimized.

Show comment
Hide comment
@zulhfreelancer

zulhfreelancer commented Sep 19, 2015

This is cool!

@iiiears

This comment has been minimized.

Show comment
Hide comment
@iiiears

iiiears Sep 28, 2015

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

iiiears commented Sep 28, 2015

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

@GokulaKrishnanOoty

This comment has been minimized.

Show comment
Hide comment
@GokulaKrishnanOoty

GokulaKrishnanOoty Oct 17, 2015

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 ?

GokulaKrishnanOoty commented Oct 17, 2015

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

This comment has been minimized.

Show comment
Hide comment
@markelsoft

markelsoft Nov 22, 2015

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?

markelsoft commented Nov 22, 2015

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

This comment has been minimized.

Show comment
Hide comment
@eteache

eteache Feb 29, 2016

Today this is not working anymore.

eteache commented Feb 29, 2016

Today this is not working anymore.

@oaeide

This comment has been minimized.

Show comment
Hide comment
@krist-jin

This comment has been minimized.

Show comment
Hide comment
@krist-jin

krist-jin Apr 4, 2016

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

krist-jin commented Apr 4, 2016

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

This comment has been minimized.

Show comment
Hide comment
@MarcoBuster

MarcoBuster Apr 9, 2016

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

MarcoBuster commented Apr 9, 2016

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

@rcarubbi

This comment has been minimized.

Show comment
Hide comment
@rcarubbi

rcarubbi Apr 11, 2016

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.

rcarubbi commented Apr 11, 2016

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

This comment has been minimized.

Show comment
Hide comment
@gabouh

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

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

This comment has been minimized.

Show comment
Hide comment
@Vitorspk

Vitorspk May 13, 2016

Thanks you @oaeide it works for me too.

Vitorspk commented May 13, 2016

Thanks you @oaeide it works for me too.

@SeyedAliKia

This comment has been minimized.

Show comment
Hide comment
@SeyedAliKia

SeyedAliKia Jun 22, 2016

How to use this api for persian language ?

SeyedAliKia commented Jun 22, 2016

How to use this api for persian language ?

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Aug 7, 2016

Thanks @oaeide it works for me too.

ghost commented Aug 7, 2016

Thanks @oaeide it works for me too.

@albovieira

This comment has been minimized.

Show comment
Hide comment
@albovieira

albovieira commented Aug 24, 2016

@Qutyba

This comment has been minimized.

Show comment
Hide comment
@Qutyba

Qutyba Oct 13, 2016

Thanks @oaeide it works for me

Qutyba commented Oct 13, 2016

Thanks @oaeide it works for me

@Smile4ever

This comment has been minimized.

Show comment
Hide comment
@Smile4ever

Smile4ever commented Feb 3, 2017

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

This comment has been minimized.

Show comment
Hide comment
@azim91

azim91 Feb 3, 2017

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

azim91 commented Feb 3, 2017

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

@hmdnprks

This comment has been minimized.

Show comment
Hide comment
@hmdnprks

hmdnprks Feb 14, 2017

Thank you @rcarubbi for providing .NET helper class

hmdnprks commented Feb 14, 2017

Thank you @rcarubbi for providing .NET helper class

@acrolink

This comment has been minimized.

Show comment
Hide comment
@acrolink

acrolink Mar 25, 2017

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

acrolink commented Mar 25, 2017

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

@Nalinh

This comment has been minimized.

Show comment
Hide comment
@Nalinh

Nalinh Mar 28, 2017

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

Nalinh commented Mar 28, 2017

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

@Nalinh

This comment has been minimized.

Show comment
Hide comment

Nalinh commented Mar 28, 2017

@nguyenhungvbhp

This comment has been minimized.

Show comment
Hide comment
@nguyenhungvbhp

nguyenhungvbhp commented Aug 17, 2017

Thanks @Smile4ever

@Genius-Badger

This comment has been minimized.

Show comment
Hide comment
@Genius-Badger

Genius-Badger Oct 8, 2017

It now returns a 503 ERROR

Genius-Badger commented Oct 8, 2017

It now returns a 503 ERROR

@cathhriss

This comment has been minimized.

Show comment
Hide comment

cathhriss commented Nov 17, 2017

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