Talking domoticz with voicerss api

Moderator: leecollings

Post Reply
BobbyNL
Posts: 12
Joined: Monday 02 February 2015 16:15
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Talking domoticz with voicerss api

Post by BobbyNL »

The goal is to let domoticz talk with a good audible voice.
Google TTS is not working because it blocks with more then one request. So i found http://http://www.voicerss.org created an account for free and you get an API key.
But until now it is not working. Somebody an idee to let this work?



Here are my scripts.

script: script_device_Keuken.lua in /domoticz/scripts/lua/
local Keuken = 'Talk - Test'

commandArray = {}

if (devicechanged["Keuken"] == 'On') then
os.execute("/home/pi/domoticz/scripts/voice_rss.sh Dit is een test")
commandArray["Keuken"]='Off'
end
return commandArray


script: voice_rss.sh in /domoticz/scripts/
#!/bin/bash
say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "http://api.voicerss.org/?key=youreapikey&hl=nl-nl&src=$*"; }
say $*
Rpi-Domoticz +RFXtrx433E | Rpi-Openelec | Rpi-Runeaudio | unRaid 6 server | Intel NUC-Linux Tvheadend + Oscam
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Talking domoticz with voicerss api

Post by G3rard »

I am using voicerss as well and it is working here. I use the following url.

Code: Select all

https://api.voicerss.org/?key<key>&c=mp3&f=16khz_8bit_mono&hl=nl-nl&r=0&src=<message>
I am using it in a script which had issues when there are spaces between the words in the message, so I replaced those with %20.
Not using Domoticz anymore
BobbyNL
Posts: 12
Joined: Monday 02 February 2015 16:15
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Talking domoticz with voicerss api

Post by BobbyNL »

thx Grard

I finaly got it working with this voice_rss.sh

#!/bin/bash
mplayer -ao alsa -noconsolecontrols "http://api.voicerss.org/?key=<key>&hl=nl-nl&src=$*"

And my mistake was to create an script with windows notepad :oops: :oops:
Rpi-Domoticz +RFXtrx433E | Rpi-Openelec | Rpi-Runeaudio | unRaid 6 server | Intel NUC-Linux Tvheadend + Oscam
Pjedr
Posts: 38
Joined: Friday 27 December 2013 3:13
Target OS: Linux
Domoticz version: Beta
Location: Friesland
Contact:

Re: Talking domoticz with voicerss api

Post by Pjedr »

Our systems have detected unusual traffic from your computer network. Please try your request again later. Why did this happen? http://translate.google.com/translate_t ... 0&client=#

Hello, I am over to VoicerRSS too, for the .mp3ees id did not cached already.
See code. Notice also the espeak alternative. I log every tts link, maybe it can be downloaded to cache manually later.
Quality is not as good as with Google, it sounds like someone speaking in a closet, and low bps, but good enuogh.
P.S. Also i use locking mechanism to avoid mutliple voices at the same time.

Code: Select all

#!/bin/bash
if [ -e "/var/ramdrive/domoticz" ]; then RUNDIR="/var/ramdrive"; else RUNDIR="/opt/domoticz-extra/"; fi
TEMPDIR="${RUNDIR}/temp"; LOGDIR="${RUNDIR}/log"; echo "`date` $*" >> ${LOGDIR}/${0##*/}.log;
exec 200>${TEMPDIR}/${0##*/}.lock || exit 1; flock -x 200 || { echo "ERROR: flock() failed." >&2; exit 1; }
if [[ "$*" =~ "Ferbroek" ]] || [[ "$*" =~ "procent" ]] || [[ "$*" =~ "Energie" ]]; then exit; fi
SpeakDir=${RUNDIR}/Speaking; echo SpeakDir=$SpeakDir; if [ ! -e $SpeakDir ]; then mkdir $SpeakDir; chmod -R 777 $SpeakDir;fi
if [ -e "$SpeakDir/$*.mp3" ]; then echo mplayer from cache "$SpeakDir/$*.mp3"; mplayer "$SpeakDir/$*.mp3" &> /dev/null; else # Statische teksten opslaan voor hergebruik
 sWWW="http://translate.google.com/translate_tts?tl=nl&q=$*&ie=UTF-8&total=1&idx=0&client=" #Google heeft limiet
 echo sWWW=$sWWW; echo "`date` $sWWW" >> ${LOGDIR}/${0##*/}.log 
 sWWW="http://api.voicerss.org/?key=<not_my_id_but_your_own_id>&hl=nl-nl&src=$*" #VoiceRSS gratis registreren 350 per dag http://www.voicerss.org/personel/
 echo sWWW=$sWWW; echo "`date` $sWWW" >> ${LOGDIR}/${0##*/}.log
 #say() { local IFS=+;/usr/bin/mplayer -ao alsa -really-quiet -noconsolecontrols "$sWWW"; }
 echo /usr/bin/wget -q -U Mozilla -O "$SpeakDir/$*.mp3" "$sWWW";
 save() { local IFS=+;/usr/bin/wget -q -U Mozilla -O "$SpeakDir/$*.mp3" "$sWWW"; };
 save "$*"; echo mplayer new to cache "$SpeakDir/$*.mp3"; mplayer "$SpeakDir/$*.mp3" &> /dev/null; chmod -R 777 $SpeakDir
 exec 200>${TEMPDIR}/${0##*/}.lock || exit 1; flock -x 200 || { echo "ERROR: flock() failed." >&2; exit 1; }
 # Hieronder de espeak methode als google translate of voicerss niet meer werkt
 #/usr/bin/espeak -v mb/mb-nl3 -a 80 -p 200 -s 120 "$*" --stdout | aplay
flock -u 200; fi
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: Talking domoticz with voicerss api

Post by jmleglise »

Google voice is not usable any more.
For 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: No registered users and 1 guest