Servus zusammen,
heute gibt es mal wieder ein kleines Projekt für die NodeRed Interessierten unter euch.
Die Sonos Integration in homee wird ja von vielen seit längerem gewünscht.
Zwei Dinge sind dabei von Interesse. Einmal die Einbindung der Sonos Lautsprecher als Geräte, um die Wiedergabe von Musik zu steuern. Zum anderem die Sprachausgabe von beliebigen Texten als Ansage- oder Informationsmedium.
In diesem Tutorial geht es genau um diesen zweiten Punkt: die Nutzung der Sprachausgabe über Sonos Lautsprecher in homee.
Voraussetzungen:
a) Sonos Lautsprecher
b) Raspberrypi mit NodeRed
c) Node: node-red-contrib-sonospollytts
d) ein Amazon AWS-Konto für Zugriff auf Amazon Polly Sprachausgabe
d) Homegramme mit den Texten aus homee
Eindrücke:
Vorgehen:
a) Bei Amazon AWS ein Konto anlegen , wer das nicht nicht hat. Die Services sin im 1. Jahr kostenlos, danach bewegen sich die Kosten pro Leistung (im Fall für die TTS) im Cent-Bereich.
b) Danach in der Management Console Anlage eines IAM-Benutzer nur für den Polly Dienst. Man bekommt damit einen Benutzernamen, einen Accesskey und einen Secretkey. Diese Daten braucht man dann in NodeRed.
c) In NodeRed Einrichten des sonospollytts node mit Eingabe der Amazon Daten sowie der IP des Sonos-Lautsprechers. Zusätzlich kann man 4 verschiedene deutsche Stimmen auswählen.
d) In homee Anlage von Webhooks mit verschiedenen Text-Nachrichten.
Beispielflow:
[{"id":"9174ad5f.70b808","type":"sonospollytts","z":"2cc975df.7f8f7a","name":"","voice":"48","ssml":false,"dir":"/tmp","sonosipaddress":"192.168.1.113","sonosvolume":"70","sonoshailing":"0","noderedipaddress":"192.168.1.144","noderedport":"1880","config":"81d413f5.ee44e8","x":710,"y":4380,"wires":[[]]},{"id":"b69afde7.4c49a","type":"inject","z":"2cc975df.7f8f7a","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":350,"y":4440,"wires":[["5712b39d.5abc8c"]]},{"id":"5712b39d.5abc8c","type":"function","z":"2cc975df.7f8f7a","name":"Sample function 1","func":"// The simplest way\nmsg.payload=\"Benvenuti,Wilkommen,Wellcome!\";\nreturn msg;\n","outputs":1,"noerr":0,"x":510,"y":4440,"wires":[["9174ad5f.70b808"]]},{"id":"7834e660.481d18","type":"inject","z":"2cc975df.7f8f7a","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":350,"y":4480,"wires":[["ba7914e8.37fd28"]]},{"id":"ba7914e8.37fd28","type":"function","z":"2cc975df.7f8f7a","name":"Sample function 2","func":"// Set the Volume\nmsg.volume=\"60\"; // If not set, will take the volume from setting page\nmsg.payload=\"Benvenuti,Wilkommen,Wellcome!\";\nreturn msg;\n\n","outputs":1,"noerr":0,"x":510,"y":4480,"wires":[["9174ad5f.70b808"]]},{"id":"9b1f0f5f.9576f8","type":"inject","z":"2cc975df.7f8f7a","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":350,"y":4520,"wires":[["4af84cb2.270eac"]]},{"id":"4af84cb2.270eac","type":"function","z":"2cc975df.7f8f7a","name":"Sample function 3","func":"// Create an array of messages\nvar aMessages=[];\n// Add random messages\naMessages.push({volume:\"50\",payload:\"Benvenuti.\"});\n// Wheater in Italy\naMessages.push({volume:\"40\",payload:\"http://media.ilmeteo.it/audio/2018-03-31.mp3\"});\n// Add random messages\naMessages.push({volume:\"30\",payload:\"Cambia la tua voce nei settaggi.\"});\nreturn [aMessages];\n","outputs":1,"noerr":0,"x":510,"y":4520,"wires":[["9174ad5f.70b808"]]},{"id":"cba2165.c9f6168","type":"inject","z":"2cc975df.7f8f7a","name":"Guten Morgen!","topic":"","payload":"Guten Morgen!","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":380,"y":4400,"wires":[["9174ad5f.70b808"]]},{"id":"18aad97d.030f37","type":"comment","z":"2cc975df.7f8f7a","name":"PUSH THE BUTTONS!","info":"","x":380,"y":4360,"wires":[]},{"id":"1ae219a4.028f26","type":"change","z":"2cc975df.7f8f7a","name":"msg-change","rules":[{"t":"move","p":"payload.On","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":4320,"wires":[["9174ad5f.70b808","fecad966.407f9"]]},{"id":"c12d5a2c.2f96","type":"http in","z":"2cc975df.7f8f7a","name":"Webhook von homee","url":"/tts","method":"post","upload":false,"swaggerDoc":"","x":380,"y":4320,"wires":[["1ae219a4.028f26"]]},{"id":"fecad966.407f9","type":"debug","z":"2cc975df.7f8f7a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":4260,"wires":[]},{"id":"81d413f5.ee44e8","type":"sonospollytts-config","z":"","name":"PollyAWS"}]
Fragen, Anregungen, Hinweise:
Sind gerne willkommen!
Viel Spaß beim Selbermachen!
VG
Michael