Google voice in Wiki

Moderator: leecollings

Post Reply
oopee
Posts: 40
Joined: Monday 12 August 2013 11:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.x
Location: Finland
Contact:

Google voice in Wiki

Post by oopee »

Google translate https://www.domoticz.com/wiki/Google_voice has changed resulting error 503 when using script from Wiki. Browser shows a captcha dialogue now.
To get it working again, a string "&ie=UTF-8&total=1&idx=0&client=t" must be added to the script.
My current script for speaking Domoticz is now:

Code: Select all

#!/bin/bash
say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?tl=fi&q=$*&ie=UTF-8&total=1&idx=0&client=t"; }
say $*
There may be other (better?) ways to fix this issue but this was the first I found.
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Google voice in Wiki

Post by pvm »

Thnx! Was looking for this for my Bluetooth speaker
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Google voice in Wiki

Post by ThinkPad »

Feel free to change the wiki, login credentials are the same as for this forum :)

Thanks for reporting.
I am not active on this forum anymore.
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Google voice in Wiki

Post by pvm »

pvm wrote:Thnx! Was looking for this for my Bluetooth speaker
Too bad...it does not work for me:

Code: Select all

pi@raspberrypi ~/btaudio $ wget "http://translate.google.com/translate_tts?tl=nl&q=test&ie=UTF-8&total=1&idx=0&client=t"
--2015-08-11 11:19:46--  http://translate.google.com/translate_tts?tl=nl&q=test&ie=UTF-8&total=1&idx=0&client=t
Resolving translate.google.com (translate.google.com)... 173.194.65.113, 173.194.65.100, 173.194.65.101, ...
Connecting to translate.google.com (translate.google.com)|173.194.65.113|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2015-08-11 11:19:46 ERROR 403: Forbidden.
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
oopee
Posts: 40
Joined: Monday 12 August 2013 11:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.x
Location: Finland
Contact:

Re: Google voice in Wiki

Post by oopee »

If you try your string (from same network as your Domoticz) http://translate.google.com/translate_t ... 0&client=t in browser, do you get it spoken and without captcha?
My error was 503, not 403. Without the added part, do you get 503?
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Google voice in Wiki

Post by pvm »

Yes I do, I seem to have another issue. I am able to download files from the internet on my Pi. Internet access seems ok
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
oopee
Posts: 40
Joined: Monday 12 August 2013 11:15
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.x
Location: Finland
Contact:

Re: Google voice in Wiki

Post by oopee »

It might be that with WGET you need to fake some HTTP headers if possible. See: http://stackoverflow.com/questions/9893 ... speech-api.
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Google voice in Wiki

Post by pvm »

oopee wrote:It might be that with WGET you need to fake some HTTP headers if possible. See: http://stackoverflow.com/questions/9893 ... speech-api.
Thnx, the following produces a valid mp3 file

Code: Select all

curl 'http://translate.google.com/translate_tts?ie=UTF-8&q=Hello&tl=en&client=t' -H 'Referer: http://translate.google.com/' -H 'User-Agent: stagefright/1.2 (Linux;Android 5.0)' > google_tts.mp3
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Google voice in Wiki

Post by pvm »

I added this information to the google_voice wiki page
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
uNGam3R
Posts: 11
Joined: Wednesday 24 December 2014 13:23
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Toulouse, France
Contact:

Re: Google voice in Wiki

Post by uNGam3R »

Thanks, your solution works great :)
---------------------------------------
Want more about Domoticz scripts and DiY devices?
Go to ---------- http://mydomotic.blogspot.com
BobbyNL
Posts: 12
Joined: Monday 02 February 2015 16:15
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Google voice in Wiki

Post by BobbyNL »

is there someone who can create a working google_voice.sh file and a sample script_device_switch.lua?

i have sound working on my rpi (can play a mp3 file with mplayer) but google.translate produces no sound even when the script is triggered.
So i think my google_voice.sh and script_device_switch isnt correct.
Rpi-Domoticz +RFXtrx433E | Rpi-Openelec | Rpi-Runeaudio | unRaid 6 server | Intel NUC-Linux Tvheadend + Oscam
BobbyNL
Posts: 12
Joined: Monday 02 February 2015 16:15
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Google voice in Wiki

Post by BobbyNL »

Could not get it working with google text to speech because google blocks my ip after one request.
So I had to find another solution. Now it works with the voicerss api.

I created a wiki page how I did it: http://www.domoticz.com/wiki/Rss_voice
Rpi-Domoticz +RFXtrx433E | Rpi-Openelec | Rpi-Runeaudio | unRaid 6 server | Intel NUC-Linux Tvheadend + Oscam
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Google voice in Wiki

Post by pvm »

Indeed Google blocks, thats why you can use:
pvm wrote: Thnx, the following produces a valid mp3 file

Code: Select all

curl 'http://translate.google.com/translate_tts?ie=UTF-8&q=Hello&tl=en&client=t' -H 'Referer: http://translate.google.com/' -H 'User-Agent: stagefright/1.2 (Linux;Android 5.0)' > google_tts.mp3
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Google voice in Wiki

Post by pvm »

Btw, Amazon its tts sounds better than googles. You need a free developers license though. I am using that one
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
BobbyNL
Posts: 12
Joined: Monday 02 February 2015 16:15
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Google voice in Wiki

Post by BobbyNL »

And what code do you use the bash file ?
Rpi-Domoticz +RFXtrx433E | Rpi-Openelec | Rpi-Runeaudio | unRaid 6 server | Intel NUC-Linux Tvheadend + Oscam
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: Google voice in Wiki

Post by pvm »

BobbyNL wrote:is there someone who can create a working google_voice.sh file and a sample script_device_switch.lua?

i have sound working on my rpi (can play a mp3 file with mplayer) but google.translate produces no sound even when the script is triggered.
So i think my google_voice.sh and script_device_switch isnt correct.
What happend on command line (no script) if you produce the mp3 file and step 2 play it with mplayer?
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
BobbyNL
Posts: 12
Joined: Monday 02 February 2015 16:15
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Google voice in Wiki

Post by BobbyNL »

it works for a few requests. But after a while i get this error.

Code: Select all

pi@raspberrypi ~/domoticz/scripts $ sudo ./google_voice.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1771  100  1771    0     0   3495      0 --:--:-- --:--:-- --:--:--  4052
Creating config file: /root/.mplayer/config
MPlayer svn r34540 (Raspbian), built with gcc-4.6 (C) 2000-2012 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing google_tts.mp3.
libavformat version 53.21.1 (external)
Mismatching header version 53.19.0
libavformat file format detected.
[mp3 @ 0xb5da2850]Header missing
[mp3 @ 0xb64800e8]Could not find codec parameters (Audio: mp3, 0 channels, s16)
[mp3 @ 0xb64800e8]Estimating duration from bitrate, this may be inaccurate
LAVF_header: av_find_stream_info() failed

Exiting... (End of file)
And opening the mp3 file. Looks clear to my that the server blocks my IP even with this mp3 (solution)

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="viewport" content="initial-scale=1"><title>http://www.google.com/</title></head>
<body style="font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px;" onload="e=document.getElementById('captcha');if(e){e.focus();}">
<div style="max-width:400px;">
 <hr noshade size="1" style="color:#ccc; background-color:#ccc;"><br>


  <div style="font-size:13px;">
   Our systems have detected unusual traffic from your computer network.  Please try your request again later.  <a href="#" onclick="document.getElementById('infoDiv0').style.display='block$
   <div id="infoDiv0" style="display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;">
    This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the <a href="//www.google.com/policies/terms/">Terms of$
   </div><br>

 IP address: xx.xxx.xx.xx<br>Time: 2015-11-01T16:26:59Z<br>URL: http://www.google.com/<br>
 </div>
</div>
</body>
</html>
Rpi-Domoticz +RFXtrx433E | Rpi-Openelec | Rpi-Runeaudio | unRaid 6 server | Intel NUC-Linux Tvheadend + Oscam
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: Google voice in Wiki

Post by jmleglise »

Google voice controls the number of call per IP. So if you have a dynamic IP, and are not lucky, you may be banned.
If so, use VoiceRSS. I have updated the wiki with a VoiceRSS howto, look here : https://www.domoticz.com/wiki/Talking_Domoticz
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest