Domoticz voice feedback (text to speech)

Tutorial Domoticz Speaker

Voice feedback is great when you want to use Domoticz for example as an alarm. In this way, Domoticz, via Text to Speech 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 for text to speech, 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

cd /usr/local/bin
sudo wget -O izsynth
sudo chmod 755 izsynth

Configuring 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:

  1. From command line specifying the options (izsynth -h to list available options or izsynth -E for example usage)
  2. Using an external config file for overriding the izsynth variables (suggested method)
  3. 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: $HOME/.config/izsynth/izsynth.conf using the command:

$ izsynth -C

After configuring you can test and use it.

Let Domoticz speak

izsynth -e naturalreaders -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: script://izsynth device activated
    • in the Off Action: put a command like this: script://izsynth device deactivated

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

An example of Text to speech voice feedback

save a phrase as mp3 in /home/pi/domoticz/phrases
test the command in SSH:

/usr/bin/mplayer /home/pi/domoticz/phrases/Alarm_activated.mp3

Modular speak script for Lua events

Create a script, this script is modular and expects a language and a phrase as variable.
killall mplayer
izsynth -e google -v "$1" -t "$2"
#izsynth -e google -v nl'text here'

give it execute rights.
chmod +x

test the script in Putty before execute it from LUA:
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.
os.execute("sh /home/pi/domoticz/scripts/bash/ '" .. speakLanguage .. "' '" .. speakMessage .. "' ")

Text to Speech alternatives and more info

Voice feedback through Amazon Alexa and Google Home and other examples and systems check out: