Rss voice

From Domoticz
Jump to: navigation, search
Look here for a up to date HowTo : https://www.domoticz.com/wiki/Talking_Domoticz

Purpose

This script generates an mp3 file with the specified text and will play it. It is useful to allow domoticz to give voice notifications.

Dependencies - hardware / software / operating system

  • You need an account for the api.voicerss
  • To play the mp3 file you need to install mplayer
  • choose the right audio output of the RPI
  • Make sure you have internet connection


Domoticz Setup - switches, variables, version

NA

Installation instructions

- First where going to install mplayer and testing it
sudo apt-get install mplayer
- Set audio output to the 3.5mm jackplug
sudo amixer cset numid=3 1
- Testing the output settings
speaker-test –t sine –f 600

Voicerss account for api key

You need to create an account on http://www.voicerss.org to get an api key. This api key is needed in the bash script.

Bash script

- Creating the script and give the appropriate rights
- location: /home/pi/domoticz/scripts/voice_rss.sh

sudo nano voice_rss.sh

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

sudo chmod 755 voice_rss.sh

Check rights with: ls -l

Lua script

- Creating the script and give the appropriate rights
- Location: /home/pi/domoticz/scripts/lua/script_device_switch.lua

sudo nano script_device_switch.lua

commandArray = {}<br>
if (devicechanged["Switch"] == 'On') then<br>
os.execute("/home/pi/domoticz/scripts/voice_rss.sh Hello world.")<br>
commandArray["Switch"]='Off'<br>
end<br>
return commandArray

sudo chmod 644 script_device_switch.lua

Check rights with ls -l