Die inoffizielle Google Text-To-Speech API

gtts

The fact that Googles Translation-Application translate.google.com offers the possibility to readout an inserted text (TTS text to speech), is nothing new. The specialty, however, are the possibilities that arise through this feature.
 
The data for the audio output is in fact called by a simple HTTP GET (REST) ​​request:
 
http://translate.google.com/translate_tts?tl=de&q=text
 
 
By this request, which provides an MP3 file, can easily realize TTS-applications and works, thanks to the multilingualism of Google’s service, also for many other languages​​. The only drawback to this method is a limitation which allows only a maximum of 100 characters per request.
 
The main URL parameters in this case, the two for the selected language and speaking to the text:

 
In ActionScript 3 the corresponding code would look like this:
 

 

A URLRequest calls to the generated MP3 file, which is as usual in AS3 is received and played.
For a practical application the code had to convert the umlauts “ä, ü, ö” into “ae, ue, oe”, because Google’s TTS service that does not recognize them. Also Texts larger than 100 characters have to be divided into smaller sections which are requested and played one after another.
 
While testing the function I noticed that Google had a latency between 600ms up to 1.5seconds. So sentences, which had to be separated because of the length, were played with a large gap in between some Words. An optimization would be if the new MP3-pard would load while the previous part is played.
 
Demo-App soon…
 
 
 

12 thoughts on “Die inoffizielle Google Text-To-Speech API

  1. ==Für einen praktischen Einsatz müsste der Code natürlich noch Umlaute in “ae, ue, oe” umwandeln, da Googles TTS-Service diese nicht erkennt==

    Wenn es für Sie immer noch interessant wäre…
    1. Ich habe mit dem kyrillischen Zeichensatz und Russisch experimentiert (tl=ru). Man benötigt dann unbedingt das paramater ie=UTF-8, dann wird der Text erkannt. Ich glaube, für die deutschen Sonderzeichen gilt dasselber.
    2. Ich musste das einfache php-Proxy nutzen, sonst ging es nicht. Was User-Agent beinhalten muss und welche Header noch wichtig sind, weiß ich im Moment nicht und wollte eigentlich Sie fragen :).

    Ach ja, ich habe mit AIR experimentiert.

  2. Hey,
    I’d just like you to know, special chars like ä, ö and ü actually are supported now.

    Does anybody know about alternate voices? ^^
    The standard german one sounds pretty horrible 😀

    Aiyion.

  3. Stand 01.08.2015 hat Google diesen Service eingeschränkt,
    Anfragen können nur noch über den Browser gestellt werden wenn ein Captcha’ beantwortet wird.
    Somit ist eine KommandozeilenAbfrage in einer Batch leider nicht mehr möglich. Schade.

    Bitte Posten wenn jemand eine Lösung hat.

    Gruß
    Reinhard

  4. Funktioniert leider nicht!

    Google antwortet mit HTML Code, der unter anderem beinhaltet:

    “To continue, please type the characters below:”

    Vermutlich hat Google irgendwann festgestellt, dass der Request automatisiert durchgeführt wird und unterbindet dies nun durch Captcha-Code.

    Kennt jemand Alternativen, oder einen Trick?

    @Aiyion.Prime
    The german Sound “Steffi” is even worse.

Leave a Reply