tl= <-Language->
q= <-Text->
In ActionScript 3 the corresponding code would look like this:
- var sayWhat:String = “Hallo, wie geht es dir? “;
- var lang:String = “de”;
- // sayWhat = “Hello, how are you?”;
- // lang = “en”;
- var req:URLRequest= new URLRequest(“http://translate.google.com/translate_tts?tl=” + lang + “&q=” + encodeURI(sayWhat))
- var snd:Sound = new Sound(req);
- if (sayWhat.length > 100){
- throw new Error(“Only phrases < 100 charakters are supported.");
- } else {
- snd.play();
- }
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”
==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.
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.
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
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.