Categories
Uncategorized

Google Text-To-Speech (TTS)

This demo no longer works due to changes with the Google Translate TTS API (which was not public to begin with, so this was bound to happen). The post remains here for archival purposes.

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!

45 replies on “Google Text-To-Speech (TTS)”

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.

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;
		}
	},
});

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!

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?

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

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:

Try to type in:
lollilollilollilollilollilollilollilollilollilollilollilollilollilollilollilollilollilollilollilolli

Funny!

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?

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.

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.

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

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.

I have been using the google translate_tts for 6 or 8 months now calling it from wget to create a .mp3. workED great until 2 days ago (july 29, 2015). google has put a captcha on it when you call it from a web browser and it returns a 503 service not available when called from wget. I haven’t determined if its temporary from overuse (i use it about 100x/day i would guess), but it seems permanent (ie it doesn’t come back on next day).

frowny face.

anyone know a workaround? or is this service no longer unavailable as a free webservice?

Thank you, thank you Samuel! Using that additional parameter I was able to fix a script that had stopped working that announces the currently playing song in my playlist.

Leave a Reply

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