Weston Ruter

Web application developer in Portland, Oregon

Google Text-To-Speech (TTS)

By

Update : Andufo shared the happy news that more languages are now available in the Google TTS service! I have added a new language selection drop-down for English, Spanish, French, German, Italian, and Hatian Creole.

Google Translate announced the ability to hear translations into English spoken via text-to-speech (TTS). Looking at the Firebug Net panel for where this TTS data was coming from, I saw that the speech audio is in MP3 format and is queried via a simple HTTP GET (REST) request: http://translate.google.com/translate_tts?tl=en&q=text. Google Translate notes that the speech is only available for short translations to English Now multiple languages are supported, and it turns out that the TTS web service is restricting the text to 100 characters. Another restriction is that the service returns 404 Not Found if the request includes a Referer header (presumably one that is not for translate.google.com).

In spite of the limitations of the web service which certainly reflect the intention that the web service is only to be used by Google Translate, thanks to the new HTML5's Audio element and rel="noreferrer", the service may be utilized by client-side web applications like following (Google Chrome 4 recommended):

Google Text-To-Speech (TTS)

I am really excited at the prospect of text-to-speech being made available on the Web! It's just too bad that fetching MP3s on an remote web service is the only standard way of doing so currently; modern operating systems all have TTS capabilities, so it's a shame that web apps and can't utilize them via client-side scripting. I posted to the WHATWG mailing list about such a Text-To-Speech (TTS) Web API for JavaScript, and I was directed to a recent thread about a Web API for speech recognition and synthesis.

Perhaps there is some momentum building here? Having TTS available in the browser would boost accessibility for the seeing-impaired and improve usability for people on-the-go. TTS is just another technology that has traditionally been relegated to desktop applications, but as the Open Web advances as the preferred platform for application development, it is an essential service to make available (as with Geolocation API, Device API, etc.). And besides, I want to build TTS applications and my motto is: If it can't be done on the Open Web, it's not worth doing at all!

Comments

  1. Paul Irish

    Nice! smooth moves with rel="noreferrer" :)

  2. Clochix

    You can easily create a TTS web service with existing softwares. Here’s an example (sorry, in french) of my own TTS-WS that I call from a Firefox Ubiquity command : http://www.clochix.net/post/2009/03/14/Et-en-plus-il-parle

  3. Ajaxian » Text to Speech via HTML5 Audio

    [...] Ruter has created a nice mashup that marries HTML5 Audio support in modern browsers with the new Google Translate API that does text to speech (for them): Recently [...]

  4. Dave

    They should do this for the pronunciation guides after names on Wikipedia. I have no idea what those crazy IPA symbols are supposed to represent, but I’m guessing they can be easily translated to speech.

  5. The Unofficial Google Text-To-Speech API

    [...] no official API for the text-to-speech service. But Weston Ruter noticed that anyone can access the service in the same way Google does: “Looking at the Firebug Net [...]

  6. Miguel

    That would be even better with forvo.com pronunciations.

  7. Google 文字转语音 API 曝光,让 Google 对你说话 | 谷奥——探寻谷歌的奥秘

    [...] Weston Ruter发现了一个Google官方并未宣布的文字转语音API,可以将任何你输入的文字实时转换成语音播放出来,是由一个女性的声音合成出来的。比如进入下面这个地址,教Google这个老外说“我爱谷奥”试试看: [...]

  8. Googleのテキスト読み上げ非公式API発見

    [...] RuterはGoogleに限らず誰でもこの機能を呼び出せることに気づいた。 このTTS データが送られて来るところをFirebug [...]

  9. Chris

    Here is a quick ubiquity hack to have the Google translator speak to you. In order to prevent it from trying to speak after every character, I required that the last character is a period, a forward slash(/) or a question mark before it will say the phrase. Try something like: Google is amazing.

    Just a thought.

    CmdUtils.CreateCommand({
    	names: ["say"],
    	arguments: [{role: "object",
    		nountype: noun_arb_text,
    		label: "your shout"}],
    	preview: function( pblock, arguments ) {
    		var text = arguments.object.text;
    		if(text.match(/[\/\.\?]$/)) {
    			var msg = 'Test';
    			pblock.innerHTML = msg;
    		}
    	},
    });
  10. Reach a Larger Audience with Content Translation Tools

    [...] Additionally, Google Translate recently announced Text to Speech support, and Weston Ruter released a script that combines this with HTML5 audio. [...]

  11. Earnest7

    Thx for info. Has anybody been able to use the TTS web service outside the box? — I mean content outside the text box that is linked some way. We are a group working to make language learning available on the global web (http://elguides.cc/resources.html).

  12. Eric

    Has anyone created a website form where the submit button gets sent off using some service/code that results in a telephone call using the text to speech technology?

    I’m in need of this for a website I’m building. Can someone point me to code or a free service I can use to accomplish this?

    Thanks!

  13. Nehad

    Is it only in English ? waiting for Google tts in all languages ^___^

  14. billy

    i like to make it say funny stuff

  15. andufo

    just tried this:
    http://translate.google.com/translate_tts?tl=fr&q=Bonjour

    It works too! (french, spanish, italian, german)

  16. Weston Ruter

    @andufo: Thank you!! I added a language selection drop-down.

  17. andufo

    Hi Weston, this is great (thank you for the post). I have 2 doubts, though:

    1) is there any parameter to configure the typ of voice used in the TTS? (male, female, robot)

    2) do you know if google is planning to release an official-open API for the TTS service?

  18. Weston Ruter

    @andufo, thanks. Not sure about either: There are no voice font parameters (gender, pitch, speed, etc.) that I am aware of. And I am not aware if Google is planning on supporting this TTS service as an official public API. We can only hope! I hope any such future API would also include the time indicies for each of the words in the audio so that a “read-along” app could be automated: http://weston.ruter.net/projects/html5-audio-read-along/

  19. Peter

    Check out JSonic which includes a Python TTS web service you can run in your own domain plus a JS lib for multichannel speech and sound. http://github.com/parente/jsonic

  20. Gus

    They’ve added a bazillion (ie, 27) new TTS languages: http://googletranslate.blogspot.com/2010/05/giving-voice-to-more-languages-on.html

  21. Joe Shelley

    There’s also a nice jQuery TTS plugin and API over at http://www.jtalkplugin.com. No download at the moment though :(

  22. Petter Kjelkenes

    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

  23. brian

    This seems not to work anymore … anyone else?

  24. Xzone9

    … Yes it seems to work just fine (Windows, Google Chrome)

  25. Otacon22

    It does not work anymore since google enabled the support for other languages with a different system..
    I’m on linux with google chrome and what i see in the page now is:

  26. bhatah kumar

    i want to add 2000 words, but it limit to 100 words is there any other API. Is there any possible ways

  27. Poposhka

    Works for me…

    http://translate.google.com/translate_tts?tl=ja&q=%E3%81%AF%E3%81%98%E3%82%81%E3%81%BE%E3%81%97%E3%81%A6%E3%81%A9%E3%81%86%E3%81%9E%E3%82%88%E3%82%8D%E3%81%97%E3%81%8F%E3%81%8A%E3%81%AD%E3%81%8C%E3%81%84%E3%81%97%E3%81%BE%E3%81%99

  28. Poposhka

    btw. on Windows XP, running Chrome (4.1.249.1045 unknown (42898))

  29. marvinbek

    Try to type in:
    lollilollilollilollilollilollilollilollilollilollilollilollilollilollilollilollilollilollilollilolli

    Funny!

  30. Sean

    http://translate.google.com/translate_tts?tl=cn&q=????

    I would like to hear the audio from chinese (CN) when I type in a word. The question is do they use some sort of pinyin code like putting a number at the end for the tone (yi1, yi2, yi3, yi4) or does the actual chinise character need to be typed in the address bar? How do they file their chinese words? Can they be accessed?

  31. ☆Tomoaki Ueda☆

    Hi, Sean.

    http://translate.google.com/translate_tts?tl=zh_CN&q=%E4%BD%A0%E5%A5%BD%E3%80%82%E6%82%A8%E4%B9%9F%E5%8F%AF%E4%BB%A5%E8%AE%B2%E4%B8%AD%E6%96%87%E3%80%82

    You can use Google Text-To-Speech in Chinese with ‘zh-CN’.
    Please try it.

    If you are living in Taiwan, you should use ‘zh-TW’.

  32. ☆Tomoaki Ueda☆

    Sorry.
    I havd a mistake. Please use ‘zh_CN’ or ‘zh_TW’ as language code if you use Chinese.
    And you can use the original characters after ‘q=’ .

  33. anyulled

    Hi, pretty cool workaround.

    I’m giving it a try but doesn’t work on Google Chrome under Linux. Looking at the request I can see your sending the referer, so Google throws a 404.

  34. Sunjen

    Anybody knows if they plan to publish the tts libraries to use in a PC program? that would be awesome for me.. TTS voices a either bad sounding or too expensive.

  35. Nathan Schofield

    Hi all,

    I am studying chinese language and want to be able to download sounds so I can then upload them to my flash card player. Is anyone able to help show me how I would maybe enter either chinese characters/pinyin somewhere and then be able to download the mp3?

    Would really appreaciate your help – I’m no coder by the way.

    Cheers

  36. Jack Wu

    Hi, thanks for sharing. Would you please kindly let me know how I can use this in a WordPress post? Do you use plugins to allow js in the post? Any help would be highly appreciated.

  37. Weston Ruter

    Jack:
    The Google TTS API is not intended for public use. However I would recommend the SoundGecko listen button.

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>