Home Assistant Alexa 02a: How to make TTS and Announcements Better - Using Node Red
Vložit
- čas přidán 7. 09. 2024
- Get your Text to Speech Game on, this time with Alexa and Node Red. I'll show you how to extend the Voice Announcements and TTS capabilities of Home Assistant using NodeRed.
🎬 THE LINKS - Files / Help / Support:
- 🛒 Other files & Merch: store.3ative.com
- 💎 3ATIVE DISCORD: / discord
- ☕ Buy me a Coffee: www.buymeacoff...
- 💕 PATREON: / 3ative
- 💯 Get the Gadgets, Devices and Tools I use: Amazon UK: amzn.to/3uRw8fi
* As an Amazon Associate I earn from qualifying purchases. Using this link ⇈ provides small monetary support for my channel at no extra cost to you.💖
#homeassistant #alexa #tts
My GitHub page for the code I used in the Function Nodes: github.com/3at...
~-~~-~~~-~~-~
Check out: "IKEA Air Quality Sensor: 7-in-1 ESPHome Update Hack"
• Hack the IKEA Air Qual...
~-~~-~~~-~~-~
I've also uploaded another video showing my full setup and a walk-through. It may give you a few ideas:
czcams.com/video/gNrvq3Lg02A/video.html
I hope it will explain a bit more and show what sort of things can be done.
That node red flow is going to come in real handy, Thanks so much for sharing.
My pleasure fella, So glad you liked it. 👍
Wow, this is really great, I actually came here to find out how I could 'tts' a payload, and that part was left out, but I found out. The other thing with the random sentences are REALLY cool, I hope my wife will like the messages it will produce for here :-)
LOL - I hope she doesn't get too upset. Thank you for your feedback... Have fun!!!
Thank you so much, this is the clearest and most understandable tutorial on the subject.
Thank you Adrian, it's great to hear my li'tutorial is useful.
Have fun. 😎
Fantastic! make more! :)
Wow, high praise indeed from my mentor.
Thank you DrZzzs. Xx
Thanks. Very unique, great work.. Little bit advanced for me but I just managed to implement this project on my setup.
Thank you for the comment - I'm sure you'll get the hang of it with practice. 👍
Very helpful, thank you so much for supporting us with nodered! Cheers!
Happy to help, loads more to come, stay tuned. LOL
Well done, short and sweet but very powerful
I find it best to keep to just the facts. LOL
Thnak you, that hired me a lot
I guess you meant _'helped'_ LOL
Glad you liked it and found it useful. 👍
thats amazing!
I know right... having Alexa tell me my curtains are opening in many different ways, is so much fun.
Be sure to check out the rest of my Alexa playlist for other things you can do: czcams.com/video/r-pwLvCT0Bg/video.html
10 out 10 bro well explain made look easy
Thanks fella, it's always easy... when you know how LOL
Awesome... Thanks for another great master class!!!
Excellent, I love the 'Master Class' comment, thnx.
Hi! Thanks for all the good information! Any chance you show the configuración for the call service node?
Yep sure, it's like this:
Domain = notify
Service = alexa_media_[YOUR DEVICE NAME]
Data = {"message":"{{payload}}","data":{"type":"tts"}}
@@3ATIVE Thanks a lot! I just realize that you post it on your GitHub as well, sorry I didn't check all the information before asking.
@@jeucedahn Oh yeah... I forgot about that. You weren't the first to ask. :)
Great video to show building the payload - but you don't show how you're actually calling the TTS service in the blue node and what settings to use, which there isn't much information online about!
Thanks. 👍
Someone didn't watch 'Part One' LOL
I explained it here: czcams.com/video/r-pwLvCT0Bg/video.html
Has something changed since you made this? When I try, my alexa says shes having trouble accessing the simon says skill right now. It doesnt {{states.sensor.thermostat_t6_air_temperature}} part. If I take that out, she says the other words in the quotes.
Not sure, Mine still works as-is and I'm still using the same (as shown)
Nice, Video you should create more content :) I saw this on the DrZzs 12-hour live stream and I have already implemented it in some of my notification flows.
Thank you, it's so great to hear my little tutorials are useful. I've still got loads of ideas and videos to make... Stay tuned! LOL
Hi dave are these flow still working? trying the second one with no joy. i have tts working on other flows its just using the VAR in the flow i cant even get the debug node to show anything coming out, which is very straange
Hi Andy. Yeah, nothing's changed. 'var' is a JSON command to declare a variable - so, I doubt that has been re-written. 😊
Two things to note:
* Make sure everything apart from your text is all lower-case
* Ensure your Function node includes the: return msg
If you've typed everything as I've shown, there should be no problem.
Great video, thx a million. Do you mind posting how you set the attributes of a sensor as a variable?
You are welcome.
I'm not sure what you are asking - The only data I use from a sensor is its 'state'.
There are not many sensors that have usable attributes. What type of sensor are you asking about?
@@3ATIVE Sorry my bad, I misread the syntax and thought you were using the attribute of a sensor. Because to my knowledge there is no direct way to parse the attribute data directly to node red, unless you make a template sensor in HA. Btw if you could share the flow in the discription or github would be cool
Hello 😁.
For the notify tts on Alexa, we need something installed on home assistant or it's working from the nodered contrib Alexa hub?
Keep going with these videos! 😎
Yes...It's a 'Custom Component' Check out this page:
github.com/custom-components/alexa_media_player
Hi can you point me to one of your video that I can have the TTS on only on my living room dot vs all the dots in my house?.
So far I have watch some NR vid and all of my tts is saying on every dot in my house.
thanks
This video should show everything you need for that.
@@3ATIVE thanks I see that now thanks, thanks for the fast reply
am new to NR as of this weekend
Another one of my videos would be Alexa 04 - Last called Alexa. In that video where I use: 'target: sensor.last_alexa'... you'll just enter your dot's name.
@@3ATIVE Do you have any vid there when you ask Alexa to do something Alexa can give you a choice yes or no?
example: the garage door is open after 9 pm then Alex can tts and say, the garage is open too late do you want me to close it. and the reply input can be Yes or No?
I don't have one yet, I'm working on it thou.
However, DrZzz showed how to do it but, tbh it's quite complicated to setup.
Great video. Can you please show the contents of the Alexa TTS call service node? How it takes all these contents as message ?? I left the message as empty or """ alexa gives her own custom message not the data from our function hence the query
got it its "{{payload}}"
No problem, I've added a JPG to my GitHub page (See Description for the link)
@@3ATIVE Thanks
hi same way without doing any math is it possible to add 10 small motivational quotes in msg payload and let alexa randomly choose one and speak on each trigger?
Sure, that is easy. From 02:57 (Part Two) I show how to do random lines. Instead, in your Function Node just make a single array of the quotes you want:
E.G.:
var line1 = [
"Small Motivational quote 1",
"Small Motivational quote 2",
"Small Motivational quote 4",
......
"Small Motivational quote 10"
]
msg.payload =
line1[Math.floor(Math.random() * line1.length)]
return msg
Note: don't put a comma at the end of the last item in the array
@@3ATIVE thanks and reply was to quick tbh....and just now I figured out watching your other video...❤️
looking forward for more videos on node red + home assistant
@@boopeshkumarprabhakaran You are most Welcome my Friend, I'm always happy to help - If I'm awake, I'm on a PC somewhere ! LOL.
YAY, glad you not only fixed it but, watched another of my videos ! 😁
WHAT NODE ARE YOU USING TO THE ECHO?
CHECK THE GITHUB LINK IN THE DESCRIPTION - 😆
@@3ATIVE That is what I was looking for! Tks.
@@PauloAbreu Unless it's really quick / simple, I'll always upload code, images, files, etc and link them in my descriptions.
When i attempt this the debug node shows the message just fine and the call service node shows that it triggered the alexa however nothing happens and no notification is sent.
Have you got Alexa setup in Home Assistant too?
If not, please check my previous tut: czcams.com/video/r-pwLvCT0Bg/video.html
@@3ATIVE sure do and have a fair amount of call service TTS notifications already working. Just can't get the random to work
@@3ATIVE [
{
"id": "f9255d2d85ddc63a",
"type": "inject",
"z": "7471f7c6faab5a73",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 200,
"y": 1280,
"wires": [
[
"ac842e515a259f63"
]
]
},
{
"id": "ac842e515a259f63",
"type": "function",
"z": "7471f7c6faab5a73",
"name": "Random Made TTS",
"func": "var line1 = [\"Awesome, \", \"Oh wow, \", \"Excellent, \", \"Super, \"]
var line2 = [
\"This bloke \", \"3a tiv \", \"Your mate \", \"That guy \", \"3a tiv \"
]
var line3 = [
\"has made \",
\"has only gone and made \",
\"has got \",
\"has uploaded \",
\"Shared \"
]
var line4 = [
\"an excellent video, \", \"a super tutorial, \", \"another great tutorial, \", \"a great video, \"
]
var line5 = [
\"tell everyone.\", \"dont forget to hit the like button.\", \"Subscribe.\", \"did you like it?\"
]
msg.payload =
line1[Math.floor(Math.random() * line1.length)] +
line2[Math.floor(Math.random() * line2.length)] +
line3[Math.floor(Math.random() * line3.length)] +
line4[Math.floor(Math.random() * line4.length)] +
line5[Math.floor(Math.random() * line5.length)]
return msg",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 390,
"y": 1280,
"wires": [
[
"04b33268169b8167",
"6d2ce72057564459"
]
]
},
{
"id": "04b33268169b8167",
"type": "api-call-service",
"z": "7471f7c6faab5a73",
"name": "Speak Payload",
"server": "3b5708c28f627eba",
"version": 5,
"debugenabled": false,
"domain": "notify",
"service": "alexa_media_adam_s_2nd_echo_dot",
"areaId": [],
"deviceId": [],
"entityId": [],
"data": "{\t \"message\": \"{{payload}}\",\t \"data\": {\t \"type\": \"tts\"\t }\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 640,
"y": 1280,
"wires": [
[]
]
},
{
"id": "6d2ce72057564459",
"type": "debug",
"z": "7471f7c6faab5a73",
"name": "debug 1",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 620,
"y": 1240,
"wires": []
},
{
"id": "3b5708c28f627eba",
"type": "server",
"name": "Home Assistant - Overkill",
"version": 4,
"addon": false,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": ": ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "default",
"statusTimeFormat": "h:m"
}
]
@@explosiveenterprises1479 OIC, cool.
Paste in your function node code and I'll take a look
@@explosiveenterprises1479 I saw you reply but, when I went to reply it disappeared ! :(
Try Pasting it in again. Cheers.
Thanks for the video.
I'm just making my way through your alexa videos now and have my alexa responding fine within node red,
but i've set this up and copied and pasted your function code and replaced with my sensors with the line in and out etc.
But when i go to run it alexa says this..
"hmm i'm having trouble accessing your simon says EU skill right now"
i've looked for a EU skill but can't find that have you any idea ?
Cheers
Hmmm... that's a new one!
The 'Simon Says' skill is what it uses to repeat a phrase. Maybe the Amazon network has an issue in your area, I just tried it here and it's still working.
Try this, say to your Alexa: "Alexa, Simon says This is a test". If she repeats back "This is a test" it's something with your setup, maybe the country in your settings, E.G. mine is set for:
alexa_media:
accounts:
...
...
url: amazon.co.uk
@@3ATIVE
Thanks for the reply , yeah the simon says works fine when asking alexa and confirmed my url is set to .co.uk.
I'm wondering wether it's some setting i've messed with in the AWS console.
i'll look through my settings
Cheers
@@stevefromuk hey, did you ever fix this? i just tried it and get the same error
Firstly, thanks again for a helpful NodeRed tutorial. I am using the random TTS and it's working really well. I also have a node red setup to play a few of my mp3 files on alexa devices and that is working well too. However, when I try to use the random functionality with those messages, Alexa reads out the mp3 path message rather than playing the mp3 sound. If I post an export of the nodes that work and do not (via pastebin?), would you mind giving me your advice on what I may be doing wrong please?
Thanks again Darren, It's good to see another of my li' tutorials was useful for for you.
I'll be happy to have a look at your NR Flow, I block links in my CZcams comments so, go find me on Disord/Facebook/... I'm '3ATIVE' everywhere. :)
@@3ATIVE Thank you. I have Discord but I'm not sure of the etiquette for gettign on touch there. Do I find a server we are both part of and then message publicly or do I DM you? Sorry, not a big Discord user and I left FB a long time back :)No worries if it's a pain. I can split out the working service nodes and run via rand node, it's just not as smooth as your function.
@@laneyweb That's ok... I don't like Discord that much either - It's just a PM platform for me. As such you are free to contacting me: 3ATIVE#8871
Hi, Darren! Sorry to step in. Any way you could show how you manage to play the mp3s through NR?
I can play directly from HA script but I do not know how to do it in NR
Thanks in advance!
Hi blade can you show your input boolean please. As I am still learning them. Thanks
Hi Nigel. I'm not Blade LOL. I couldn't add your 'Input Boolean' question in this video. It has been answered in my next video tho.
@@3ATIVE really sorry about wrong name forgive me
@@nigelholland24 No worries fella. 😎
The Example video is up, I hope it answers your question:
czcams.com/video/gNrvq3Lg02A/video.html
Hi There! Awesome content! Keep up! Question! Is there an way to set the target to the last called echo as you did in the previous video? The below code works fine:
{
"data": {
"type": "announce",
"method": "all"
},
"title": "Test TTS"
"message": "Hi There, I can speak!",
"target": [
"media_player.echo_plus"
]
}
Wondering how to replace the "media_player.echo_plus" to a variable with the content of the "sensor.last_called_echo".
Thank you, I'm happy to hear it helped.
It's not clear where you are using that code but, this may help:
- service: media_player.play_media
data_template:
entity_id: "{{ states.sensor.last_alexa.state }}"
@@3ATIVE This code is inside the data of the "call service node". I'm not using the service as "alexa_media_echo_plus". Instead I'm just using service as "alexa_media" and pointing the target echo device in the code and I would like to make it flexible to speak in the last called echo.
I already found the aswer to that in this video at 2:28 czcams.com/video/cLv0CGgoTJ0/video.html&ab_channel=3ATIVEVFXStudio Thanks again for the great work! cheers!
@ Ah, in that case your line needs to be this:
"target": [
"{{ states.sensor.last_called_echo.state }}"
]
anyone managed to make this work in Google Nest Mini?
Once you have Google set up for TTS, this NR should be pretty much the same - as it just uses a 'Call Service' Node.
what are you using though to link alexa to nodered not for alexa speaking but to ASK alexa a question like the temperature and have that trigger the node red flow?
It's all done in Node-Red and Routines in the Alexa App. I simple create a routine that when I say "Bedroom Temperature" it fires the "Device" node in Node Red.
@@3ATIVE yeah i can do that fine with stuff in home assistant i just cant seem to link nodered up to be able to choose things in node red in a routine....
@@3ATIVE see another dead end for me :( Now I am curious how are your alexap app and nodered interconnected?
@@hamhumtube Sorry, it's not that clear in the video. In the description, I link to one of my GITHUB pages (for the code) but at the bottom is the setting for a 'Call Service' Node. This is what sends the text to the Alexa device.
Here's the link again: github.com/3ative/Making-TTS-Better-NodeRed
@@3ATIVE thank you. That node I learnt from your other video. I meant how you create routine in app to trigger nodes.
so looking to make alexa speak, and you don't even show us what node is your " speak Payload"?
This is a advanced ("Better") TTS tutorial showing mixing text snippets to randomly form sentences. Therefore, it does not go in to basic detail(s).
Please see the first video in my Home Assistant Alexa series... where I show the "Speak Payload" node:
czcams.com/play/PLWRTMby105biP9gE08iGLab1FP6n7_mka.html
Did anyone get these to work on Google home? I am struggling to get it to speak the sensor value from the msg.payload
What are you getting? - if anything.
@@3ATIVE Everything works fine, the message text is spoken, except the conversion of the sensor value is spoken as the text not the correct value. I will copy my example
"the EV6 charge is {{ states('sensor.mikes_ev6_ev_battery') }}." Google just reads this out as double squiggly brackets even though when I check it as templates it returns correct value and it matches your debug output
@@SCRAMPLER Try this:
{{states.sensor.mikes_ev6_ev_battery.state}}
@@3ATIVE no different I’m afraid
I am folowing your steps and get an error [ Call-service error. invalid template (TemplateSyntaxError: unexpected char '&' at 29) for dictionary value @ data['message']"]
with the following :
msg.payload =
"The temperature is "+
"{{states ('sensor.downstairs_temperature') }}"+ ", " +
"The thermostat is " +
"{{ states('climate.downstairs') }}" + ", " +
"and that is set to " +
"{{ states('climate.bedroom_cooling.attributes.temperature') }}"
return msg
This is the message that gets kicked over:
message: "The temperature is {{states ('sensor.downstairs_temperature') }}, The thermostat is {{ states('climate.downstairs') }}, and that is set to {{ states('climate.bedroom_cooling.attributes.temperature') }}"
Check your code against what I showed here: czcams.com/video/Ib8RffCYcfo/video.html
You have have a load of extra ( and ' added that I don't show.
E.G.
You first one should be:
"The temperature is " +
"{{states.sensor.downstairs_temperature.state}}"
@@3ATIVE Now I get:
Call-service error. UndefinedError: 'None' has no attribute 'attributes'
On the following updated function
msg.payload =
"The temperature is "+
"{{states.sensor.downstairs_temperature}}"+ ", " +
"The thermostat is " +
"{{states.climate.downstairs}}" + ", " +
"and that is set to " +
"{{states.climate.bedroom_cooling.attributes.temperature}}"
return msg
In states I get this:
Entity:
sensor.downstairs_temperature
Downstairs Temperature
State:
69.2
If I remove all {{ items I get "The temperature is" via voice TTS
@@worm-haandled4615 Again, check your code against my reply.
@@3ATIVE I did and I get a worse error after I update that. If I use the call service in developer options and paste it directly it works fine, with how I have the added items. Standard Home assistant instance and up to date. Sorry been busy at work. I really want to do the random sounding array. That is why I am practicing with this part to get it running.