Voice feedback is great when you want to use Domoticz for example as an alarm. In this way, Domoticz can tell you when the alarm is activated. I use IzSynth for this task. izSynth is a bash script running under Linux, written to automate the synthesis of voices used into izPBX System or for realtime TTS (Text To Speech) used into Home Automation solutions. It can use offline synthesis software like eSpeak, Festival, VoiceRSS, NaturalReaders, and other popular online web TTS services to synthesize audio voices from ASCII text files and automatically merging the audio with background music (mp3 and wav format are supported), adding silences and fade in and out.
Connect a speaker thought mini-jack to your PI. You can also use Bluetooth speakers, but I will focus here on a simple speaker so the Bluetooth setup is not covered in this article.
Installation of izsynth
sudo apt-get install -y sox lame mplayer curl espeak wget bsdmainutils file mawk coreutils<br>
sudo wget https://raw.githubusercontent.com/ugoviti/izsynth/master/izsynth -O izsynth<br>
sudo chmod 755 izsynth<br>
onfiguring text to speech
NB. Some engines, like voicerss, need an APY KEY before you can use it, follow the onscreen guide to get your APY KEY:
izsynth -e voicerss -H
izSynth is configurable in 3 ways:
- From command line specifying the options (to list available options or1izsynth -hfor example usage)1izsynth -E
- Using an external config file for overriding the izsynth variables (suggested method)
- Modifying the variables on the izsynth script itself (not suggested)
I suggest creating an external config file to avoid changes to your configurations when you update izSynth script.
Create the following config file:
$ izsynth -C
After configuring you can test and use it.
Let Domoticz speak
-v Peter -t "Hello Gadget freak"
- Create a virtual switch (or use a real switch or hardware sensor):
- in the On Action: put a command like this: 1script://izsynth device activated
- in the Off Action: put a command like this: 1script://izsynth device deactivated
- in the On Action: put a command like this:
This will download the phrases and save them on your Domoticz. But you can always create and save phrases by yourself to play them, so an internet connection is not needed.
create phrases with services like http://soundoftext.com
An example of voice feedback
save a phrase as mp3 in /home/pi/domoticz/phrases
test the command in SSH:
Modular speak script for Lua events
Create a script, this script is modular and expects a language and a phrase as variable.
izsynth -e google -v "$1" -t "$2"<br>
#izsynth -e google -v nl'text here'
give it execute rights.
chmod +x Play_sound.sh
test the script in Putty before execute it from LUA:
sh Play_sound.sh nl "text to test"
It will play the variable text in Dutch language (you can change this by using EN instead of NL)
This way you are able to let speak everything in Lua very simple by using: where language and message must be changed ofcourse.
<br>os.execute("sh /home/pi/domoticz/scripts/bash/Play_sound.sh '" .. speakLanguage .. "' '" .. speakMessage .. "' ")
Alternatives and more info
Voice feedback through Amazon Alexa and Google Home and other examples and systems check out: