Closed jeetzz closed 6 years ago
Google started detecting and blocking 3rd party access on their TTS API on the translate page. They seem determined to stop people from getting speech data. I'm looking for a way around but I can't promise anything yet.
Damn... :( best of luck bro!
Shit ! Just a the moment when i need use they api :/ this is bad luck :( good luck to you.
@zaf Hey Zaf did you find any solution, I really need this, actually in my system there sometime sound sometime there no sound, it's may the sound is coming the cache. Please help if you have any update
I don't think it worth trying to use this anymore. Google has decided to restrict access and even if we bypass the current restrictions it will only be temporarily I'm afraid. People should move to other TTS solutions. It was fun while it lasted ;)
If I am wrong I think they have paid API service for that $20 for million characters. Is that possible to bypass and use the cache, that will be great static tts? Please let me know if I can help with anything
I don't see any TTS API on their Developer Console page. I am aware of their android TTS API but that is a different thing.
How about this link. https://cloud.google.com/translate/v2/faq?hl=en
This is the translate API, it detects the language of some text and/or translates it to another language. There is nothing about speech synthesis there.
Ok, there any other way to get it work, by using cache.
How about voiceRSS?
We have installed a TTS engine on one of our machines in the DC, and built a webservice out of it that returns us a wav file. However I am now looking to edit the googletts.agi file to put in my server credentials so that I can stream the TTS in realtime like before. Any ideas what should I look at in googletts.agi?
taphawane: cache is enabled by default and if some prompts are alredy cached the script will use them instead of contacting the online service. But anyway this is irrelevant, you can't go far with it.
Jeetzz, the script is quite straight forward, have a look at the code and if you have any specific questions I would be glad to help.
Hi Zaf,
I have made few changes in $host variable and $lang and tried the AGI, but i get zero size file in return.
[2015-10-20 21:05:45] WARNING[9694][C-00000172]: file.c:497 filehelper: File /tmp/2174a83f4d8dc49e249b18c4484e8ffb.sln detected to have zero size.
The webservice we use is as following URL which returns a wav file for playback and is working fine.
http://ourliveip:port/tts2?i=3&t='text to speech text here'
The modified AGI is http://pastebin.com/p93z212L
If you could pls assist. Thanks
Okay, my bad. found the flaw. The service is returning the TTS in HTML streamable form, instead of MP3. But I would still appreciate if you could look at the code I've uploaded. Thanks.
I have the issue 3 days, because I have move server to a new one, I did not restore the /tmp directory to the new server, this way it's stop working, my tts is static, I just to run it again and get a the sound in cache I'm done. I am just trying to get it work just for a while. My google search I have find a URL with API key that worked without asking for Security image code. wget -U Mozilla -O output.mp3 "http://translate.google.com/translate_tts?tl=en&q=Google+TTS+is+awesome&ie=UTF-8&total=1&idx=0&client=t&key=YOUR_KEY_STRING"
I have the API key from google how can I trick it in the script?
taphawane: the request is generated in line No 198 in the agi script:
my $ua_request = HTTP::Request->new('GET' => "$url?ie=UTF-8&q=$line&tl=$lang&total=$lines&idx=$i&client=t");
by editing this you can add any extra parameters you need,
jeetzz:
Keep in mind that the agi script expects mp3 data that it then converts to wav via mpg123 and finally to 16bit slin raw data via sox. (lines 207-217) In you case you probably have to skip these steps so the script will need quite a few changes. If your TTS service produces wav data that can be played back by asterisk straight away you just have to save the data in a wav file and pass it to the playback application like the agi script does around line 220.
I think I am having another issue. If the agi script have already have cached a *.sln sound file, and that cached file is removed, does the agi script try contact google tts servers or just exit the script? Because in my agi debug I don't find log where agi script have try to reach google servers.
A fix is out for anyone interested:
https://github.com/zaf/asterisk-googletts/commit/0d790d7644ae9750a869bfc47f845391defa133b
Thanks, @zaf. I am going to test it right a way. Please give me your Paypal email, I want to donate for your time.
You are welcome @taphawane. I accept donations only in code ;) your gesture to contribute back is still much appreciated. :+1:
Regarding your issue if cache is enabled and no matching file is available the script will try to contact the remote service (google translate) in order to fetch the data. Cache checking is done here: https://github.com/zaf/asterisk-googletts/blob/master/googletts.agi#L181 and we contact the remote end here: https://github.com/zaf/asterisk-googletts/blob/master/googletts.agi#L201
17/12/2015: ERROR: root@voip:/var/lib/asterisk/agi-bin# perl ./googletts-cli.pl -t "teste" -o teste.wav Failed to fetch speech data. at ./googletts-cli.pl line 132.
And googletts.agi not working
Maybe google have blocked the API again, Mr @zaf have worked hard to make it work. But he already told everybody, that will not last long, because google is very determined to block there API, You may try to look for alternatives. This was awesome script, I have done too much with it, Thanks @zaf!
Seems like they made changes again, By the looks of it they now require some cookies and some of theese cookies seem to be set by javascript code. If that is the case it means we have to parse the javascript on the page which is not practical. I will have a closer look to make sure what is going on.
The Zaf wrote the best script of all time! Too bad Google is doing this lock, with so much useless to block, and they bloqueam a very useful service for all. Sorry for the English used the google translator ...
Too bad, I also facing the same problem today. I just did a temporary, urgent, ugly... solution, switch to other service provider. Changed line: 85 to my $url = "http://tts.voicetech.yandex.net/tts"; OR my $url = "http://tts.baidu.com/text2audio";
line: 201 to my $req = "$url?format=mp3&quality=hi&lang=en_GB&text=$line"; <- for yandex OR my $req = "$url?lan=en&ie=UTF-8&text=$line"; <- for baidu
Remarked line: 205 - 212
However, this temporary solution is much slower than googletts. Please let me know if anyone has any better temporary solution. Thank @zaf for this awesome script and hope that this can be fix asap.
any news?
No news, its either cookies or (most probably) the tk parameter that they now check to determine if the request is valid. We set this randomly and it (surprisingly) used to work but not anymore.
The token to be used is the same as Google Cloud service? https://cloud.google.com/translate/
The script was updated with a routine to calculate the token and seems to work again. All credit goes to Andre Roeder for pointing me to the solution.
The original routines are in the js code the translate page loads and more specifically here. Some good people at the translate-shell project did the daunting job of figuring out the obfuscated mess of that code. I only had to port their code to googletts scripts. All seems to work for now, but I'm afraid Google will break things again soon. Anyway kudos again to Andre and @scturtle ! Feel free to test while it still works :P
Thank Zaf! I will test tomorrow ..
Works again!
Not working for me:
-- Executing [9998@teste:3] AGI("SIP/1002-00000004", "googletts.agi,"testing google",en,any,1") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/googletts.agi <SIP/1002-00000004>AGI Tx >> agi_request: googletts.agi <SIP/1002-00000004>AGI Tx >> agi_channel: SIP/1002-00000004 <SIP/1002-00000004>AGI Tx >> agi_language: pt_BR <SIP/1002-00000004>AGI Tx >> agi_type: SIP <SIP/1002-00000004>AGI Tx >> agi_uniqueid: 1451314387.4 <SIP/1002-00000004>AGI Tx >> agi_version: 1.8.25.0 <SIP/1002-00000004>AGI Tx >> agi_callerid: 1002 <SIP/1002-00000004>AGI Tx >> agi_calleridname: Financeiro <SIP/1002-00000004>AGI Tx >> agi_callingpres: 0 <SIP/1002-00000004>AGI Tx >> agi_callingani2: 0 <SIP/1002-00000004>AGI Tx >> agi_callington: 0 <SIP/1002-00000004>AGI Tx >> agi_callingtns: 0 <SIP/1002-00000004>AGI Tx >> agi_dnid: 9998 <SIP/1002-00000004>AGI Tx >> agi_rdnis: unknown <SIP/1002-00000004>AGI Tx >> agi_context: teste <SIP/1002-00000004>AGI Tx >> agi_extension: 9998 <SIP/1002-00000004>AGI Tx >> agi_priority: 3 <SIP/1002-00000004>AGI Tx >> agi_enhanced: 0.0 <SIP/1002-00000004>AGI Tx >> agi_accountcode: 5 <SIP/1002-00000004>AGI Tx >> agi_threadid: -1259455632 <SIP/1002-00000004>AGI Tx >> agi_arg_1: testing google <SIP/1002-00000004>AGI Tx >> agi_arg_2: en <SIP/1002-00000004>AGI Tx >> agi_arg_3: any <SIP/1002-00000004>AGI Tx >> agi_arg_4: 1 <SIP/1002-00000004>AGI Tx >> <SIP/1002-00000004>AGI Rx << CHANNEL STATUS <SIP/1002-00000004>AGI Tx >> 200 result=6 -- googletts.agi: Command returned: 200 result=6 <SIP/1002-00000004>AGI Rx << GET FULL VARIABLE ${CHANNEL(audionativeformat)} <SIP/1002-00000004>AGI Tx >> 200 result=1 (ulaw) -- googletts.agi: Command returned: 200 result=1 (ulaw) -- googletts.agi: Text passed for synthesis: testing google. -- googletts.agi: Language: en, Interrupt keys: 0123456789#*, Sample rate: 8000 -- googletts.agi: Speed: 1, Caching: 1, Cache dir: /googletts_audio -- googletts.agi: URL passed: https://translate.google.com/translate_tts?ie=UTF-8&q=testing%20google.&tl=en&total=1&idx=0&textlen=15&client=t&tk=870144.745926&prev=input -- googletts.agi: Failed to fetch file. -- googletts.agi: Cleaning temp files.
The token was not calculated correctly, for the string 'testing google.' the token should be '789589.666258' in your log it was calculated as '870144.745926'. I suspect some strangeness in utf handling. Can you please give me the output of the command 'locale' in the system you ran the script?
root@voip:~# locale LANG=pt_BR LANGUAGE= LC_CTYPE="pt_BR" LC_NUMERIC="pt_BR" LC_TIME="pt_BR" LC_COLLATE="pt_BR" LC_MONETARY="pt_BR" LC_MESSAGES="pt_BR" LC_PAPER="pt_BR" LC_NAME="pt_BR" LC_ADDRESS="pt_BR" LC_TELEPHONE="pt_BR" LC_MEASUREMENT="pt_BR" LC_IDENTIFICATION="pt_BR" LC_ALL=
So you dont use utf. Looks like the routine that calculates the token doesn't currently work for non utf input.
New Locale: root@voip:~# locale LANG=pt_BR.UTF-8 LANGUAGE= LC_CTYPE="pt_BR.UTF-8" LC_NUMERIC="pt_BR.UTF-8" LC_TIME="pt_BR.UTF-8" LC_COLLATE="pt_BR.UTF-8" LC_MONETARY="pt_BR.UTF-8" LC_MESSAGES="pt_BR.UTF-8" LC_PAPER="pt_BR.UTF-8" LC_NAME="pt_BR.UTF-8" LC_ADDRESS="pt_BR.UTF-8" LC_TELEPHONE="pt_BR.UTF-8" LC_MEASUREMENT="pt_BR.UTF-8" LC_IDENTIFICATION="pt_BR.UTF-8" LC_ALL=
root@voip:~# locale -a C POSIX pt_BR.utf8
Error Debug: -- Executing [9998@teste:3] AGI("SIP/1002-00000000", "googletts.agi,"testing google",en,any,1") in new stack -- Launched AGI Script /var/lib/asterisk/agi-bin/googletts.agi <SIP/1002-00000000>AGI Tx >> agi_request: googletts.agi <SIP/1002-00000000>AGI Tx >> agi_channel: SIP/1002-00000000 <SIP/1002-00000000>AGI Tx >> agi_language: pt_BR <SIP/1002-00000000>AGI Tx >> agi_type: SIP <SIP/1002-00000000>AGI Tx >> agi_uniqueid: 1451319738.0 <SIP/1002-00000000>AGI Tx >> agi_version: 1.8.25.0 <SIP/1002-00000000>AGI Tx >> agi_callerid: 1002 <SIP/1002-00000000>AGI Tx >> agi_calleridname: Financeiro <SIP/1002-00000000>AGI Tx >> agi_callingpres: 0 <SIP/1002-00000000>AGI Tx >> agi_callingani2: 0 <SIP/1002-00000000>AGI Tx >> agi_callington: 0 <SIP/1002-00000000>AGI Tx >> agi_callingtns: 0 <SIP/1002-00000000>AGI Tx >> agi_dnid: 9998 <SIP/1002-00000000>AGI Tx >> agi_rdnis: unknown <SIP/1002-00000000>AGI Tx >> agi_context: teste <SIP/1002-00000000>AGI Tx >> agi_extension: 9998 <SIP/1002-00000000>AGI Tx >> agi_priority: 3 <SIP/1002-00000000>AGI Tx >> agi_enhanced: 0.0 <SIP/1002-00000000>AGI Tx >> agi_accountcode: 5 <SIP/1002-00000000>AGI Tx >> agi_threadid: -1270072464 <SIP/1002-00000000>AGI Tx >> agi_arg_1: testing google <SIP/1002-00000000>AGI Tx >> agi_arg_2: en <SIP/1002-00000000>AGI Tx >> agi_arg_3: any <SIP/1002-00000000>AGI Tx >> agi_arg_4: 1 <SIP/1002-00000000>AGI Tx >> <SIP/1002-00000000>AGI Rx << CHANNEL STATUS <SIP/1002-00000000>AGI Tx >> 200 result=6 -- googletts.agi: Command returned: 200 result=6 <SIP/1002-00000000>AGI Rx << GET FULL VARIABLE ${CHANNEL(audionativeformat)} <SIP/1002-00000000>AGI Tx >> 200 result=1 (ulaw) -- googletts.agi: Command returned: 200 result=1 (ulaw) -- googletts.agi: Text passed for synthesis: testing google. -- googletts.agi: Language: en, Interrupt keys: 0123456789#*, Sample rate: 8000 -- googletts.agi: Speed: 1, Caching: 1, Cache dir: /googletts_audio -- googletts.agi: URL passed: https://translate.google.com/translate_tts?ie=UTF-8&q=testing%20google.&tl=en&total=1&idx=0&textlen=15&client=t&tk=870144.745928&prev=input -- googletts.agi: Failed to fetch file. -- googletts.agi: Cleaning temp files.
Works fine in new installation...
Hello @fesalata, how did you fixed? Did you installed a new asterisk?
Hi @jeancog. Yes, unfortunately I had to completely reinstall the system. Using now:
The error is the OS version, not the version of Asterisk. My old Debian was not updated with the UTF8 locale
Hey Zaf!
Thanks so much for the scripts and all of your hard work. I have used this in a few different projects. Looks like Google has changed things up again......eerrr. Can you verify this?
"Failed to fetch Data....Line 134"
@chuckycharms The same error, look your locale...
This is my locale, this asterisk and linux install worked fine until recently:
root@pbx1:~ $ locale LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
And btw, thanks for the reply!
You changed the locale, or did the full installation? I made the change and did not work, then I did the complete installation and it worked.
I haven't changed the locale, this was from the original install.
should work ... You upgraded the new packages?
Ive replaced the googletts.pl script and the google.agi, anything else to upgrade?
test: $ git clone git://github.com/zaf/asterisk-googletts go to directory asterisk-googletts/cli/ and execute: $ perl ./googletts-cli.pl -t "testing googletts" -o test.wav
see if the error returns
Failed to fetch speech data: 403Forbidden at ./googletts-cli.pl line 134.
Hi,
Getting an error "Failed to fetch speech data. at /usr/bin/googletts-cli.pl line 126." since few days. Just wondering if there's any update that would be coming in soon?
Thanks for your help.