Autonomous TTS with Alexa
Here is how I got Alexa to announce information (text to speech) to me without asking her. You may be thinking why having Alexa (Amazon Echo) announce messages when no one is asking her?
It can be very useful, imagine that every-time someone opens an exterior door, your Alexa devices let you know 'Main door open', or if the kids switch of the video console, Alexa can let you know as soon as it happens.
A while back came across this blog entry from Lotzimmer, I thought it was brilliant and very simple to setup, at least if you are using a Linux system for your Home Automation. You can find it here:
I highly recommend you to go through the original blog post above, as there're lots more options. I just focussed on getting Alexa to work a bit like "Simon says".
1.- Download this .sh script, you will need a Linux system like a Raspberry Pi: https://github.com/EdddieN/machinon/blob/master/files/alexa_tts/Alexa_tts.sh
2.- Have a look at the code and make sure you are comfortable with what it is doing. for your interest, it is doing a CURL and JSON parsing to use the new announcing feature for Alexa
3.- Edit the file with your favourite text editor and enter your username and password you use for your Alexa account. On command line you can use:
4.- You may want to change the language Alexa speaks, the URL and the name for it, you can find this logging on your Alexa account, for example if from the UK, this would be: alexa.amazon.co.uk and amazon.co.uk
5.- If you are not sure, log into your Alexa Amazon domain and use these. You can also check the language your devices are set to.
6.- Scroll to Language, whatever language you have there, is the one you have to setup on the Alexa_tts.sh file too. (otherwise Alexa will have a terrible time synthesising your phrases!)
To make it easier I have listed here the options:
en-US = English (United States)
en-GB = English (United Kingdom)
de-DE = Deutsch
ja-JP = 日本語
en-IN = English (India)
en-CA = English (Canada)
en-AU = English (Australia/New Zealand)
fr-CA = Français (Canada) Version préliminaire
fr-FR = Français (France)
it-IT = Italiano (Italia)
es-ES = Español (España)
es-MX = Español (México)
7.- Install JQ, you can find it here: https://stedolan.github.io/jq/ or on command line just type:
sudo apt-get install jq
8.- Type on command line ./Alexa_tts.sh -a , this will show all your devices connected to your Alexa account. It should look something like this:
9.- Now is the interesting part, just type ./alexa_tts.sh -d Kitchen -e speak:'Hello, I can talk now'
-d is for the device you want to use for TTS
-e speak: is the phrase you want to synthesise, make sure there's no space between the : and the 'for the phrase, all together.
That is it, the hardest part is done. Now you can use it from your own system. Below is an example of how I use it with Domoticz to announce when someone opens the main door:
For more information about this really useful script, please visit https://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html