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
Now multiple languages are supported, and it turns out
that the TTS web service is restricting the only available for short translations to English
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):
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
!
Leave a Reply