The Unofficial Google Text-To-Speech API

google-translate-hello-worldDo you want to create your own Text-To-Speech convertor? Well, you may want to directly use Google “Unofficial” API to convert Text to Speech.

Google Translate had announced few weeks back some new enhancements. Where a new feature was added that can convert the text into speech.

Now the hack is, you can use the same feature to convert your own text into speech and generate a mp3 out of it. All you have to do it to construct a URL and hit it from browser. For example, if I want to convert text “Hello World” in speech, I will write following url in browser.


http://translate.google.com/translate_tts?q=Hello+World

And that’s it. This will generate an MP3 file which you can download and play.

You may want to create a small HTML form to convert text to speech. All you need is to copy following code and create a HTML file in your machine. And run it using any browser.

<form method="get" action="http://translate.google.com/translate_tts">
	<textarea name="q"></textarea>
	<input type="submit" value="Text-To-Speech"></input>
</form>

Currently, This “Unofficial” API is limited to 100 characters only. Also I am not till when google will support this API.

Source: Ajaxian



13 Comments

  • Cydork 16 December, 2009, 9:07

    Here is a basic bookmarklet to use the same..

    javascript:(function(){q=document.getSelection().toString();if(q){q = q.replace(/\W+/g, ‘+’);q = q.replace(/(^\+|\+$)/g, ”);location.href=’http://translate.google.com/translate_tts?q=’+q;};})()

  • matto 16 December, 2009, 13:27

    There is probably a mistake. “Text-To-Speech” has no attribute assigned. Or is it intentional?

    Great tip though.

  • Luciano 16 December, 2009, 15:20

    Already removed…

  • Viral Patel 16 December, 2009, 19:15

    @Cydork – Thanks for the bookmarklet. :)
    @matto – Thanks for pointing out the typo. I have updated the code.
    @Luciano – The API is still working for me. I am able to get the mp3.

  • ram 16 December, 2009, 23:29

    Ultimate one……………..

  • SMiGL 21 December, 2009, 13:01

    Simple but very helpful :)

  • Stefan 1 January, 2010, 21:00

    I get ja 404 error :-(

  • Anil Kumar Panigrahi 26 March, 2010, 0:05

    Thank you, API is working fine ., it is helpful

  • ango 19 August, 2010, 6:48

    Does it support other language, such as Chinese?

  • Petter Kjelkenes 3 September, 2010, 4:42

    I have created a PHP class wrapper with features such as unlimited characters (google limits to 100). The class also includes methods to include javascript and play characters in real time without any visable player.

    Based on:
    * Jquery
    – Jplayer
    – Hotkey
    * Googles TTS API

    Check it out @ pkj’s developer blog:
    http://pkj.no/content/googles-tts-api-power-php

    Also available to download.

  • Gersom 5 January, 2011, 20:02

    Im using this program now for a while, but i can’t figure out how it knows what language to use. Sometimes it’s English, but most of the time Dutch (my language). It seems to have a will of its own :-) How does this work?

  • David 7 April, 2013, 3:31

    I wish Google would increase the 100 character limit.

Leave a Reply

Your email address will not be published. Required fields are marked *

Note

To post source code in comment, use [code language] [/code] tag, for example:

  • [code java] Java source code here [/code]
  • [code html] HTML here [/code]

Current ye@r *