RSS voice

Moderator: leecollings

Post Reply
Qcvictor
Posts: 22
Joined: Wednesday 08 April 2015 3:13
Target OS: Linux
Domoticz version: Beta
Location: Canada
Contact:

RSS voice

Post by Qcvictor »

I trying to make talking domoticz, i followed the wiki without any issue,
I cut and paste the script_device_switch.lua from wiki and create the "Switch"
when I run the script a get this error
2016-04-06 17:29:28.027 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_switch.lua: /home/pi/domoticz/scripts/lua/script_device_switch.lua:2: unexpected symbol near 'if'
2016-04-06 17:29:28.018 (Switch) Light/Switch (Switch)
I cut and paste the script_device_switch.lua from wiki and create the "Switch"
Pjedr
Posts: 38
Joined: Friday 27 December 2013 3:13
Target OS: Linux
Domoticz version: Beta
Location: Friesland
Contact:

Re: RSS voice

Post by Pjedr »

My script (I even tried flashing a led on each word):

Code: Select all

#!/bin/bash
if [ -e "/var/ramdrive/domoticz" ]; then RUNDIR="/var/ramdrive"; else RUNDIR="/opt/domoticz-extra/"; fi
TEMPDIR="${RUNDIR}/temp"; SCRIPTSDIR="${RUNDIR}/scripts"; LOGDIR="${RUNDIR}/log"; echo "`date` $*" >> ${LOGDIR}/${0##*/}.log;
exec 200>${TEMPDIR}/Espeak.lock || exit 1; flock -x 200 || { echo "ERROR: flock() failed." >&2; exit 1; }
if [[ "$*" =~ "Verbruik" ]] || [[ "$*" =~ "procent" ]] || [[ "$*" =~ "Energie" ]]; then exit; fi
SpeakDir=${RUNDIR}/Speaking; echo SpeakDir=$SpeakDir; if [ ! -e $SpeakDir ]; then mkdir $SpeakDir; chmod -R 770 $SpeakDir;fi
if [ -e "$SpeakDir/$*.mp3" ]; then echo "Playing \""$SpeakDir/$*".mp3\" from cache."; 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=yourkey=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 "Playing \""$SpeakDir/$*".mp3\" new to cache."; chmod -R 770 $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
fi;
#words=($*); echo Aantal letters = ${#words}, Aantal woorden = ${#words[@]}
#$SCRIPTSDIR/FunWithLedStripsLoops.sh AllBluesOnOff ${#words[@]} 0.15 &
#$SCRIPTSDIR/FunWithLedStripsLoops.sh AllBluesLeftRight ${#words[@]} 0.15 &
mpg123 "$SpeakDir/$*.mp3" &> /dev/null;
flock -u 200

Call this from lua script:

Code: Select all

sSpeak=sScriptsDir..'/Espeak_nl.sh'
sMsg='What ever you want to be said.'
os.execute('nohup '..sSpeak..' '..sMsg..' 2>/dev/null &')
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest