No announcement yet.

Alexa TTS that works better (IMHO) than the solution for Home Assistant.

  • Filter
  • Time
  • Show
Clear All
new posts

    Alexa TTS that works better (IMHO) than the solution for Home Assistant.

    OK, so there's many ways to skin a cat and I personally find this better than the solution for HomeAssistant and better than the ChromeCast Plugin ( it is for me, not here to start a debate). While I got HomeAssistant kind of, sort of working semi well I had issues with cookies and the interface (or lack there of) was limiting.
    Chromecast works beautifully on a Google Home, but I'm stuck in the Amazon echo-system and using it for announcements having both in a box kind of works but the sound quality is poor and there's a long delay, so...

    This solution requires Node-Red
    Maybe you can port it, but then again, a PI Zero W is $5 so it's hardly worth the hassle even if you'd only run this application.
    I find myself using it as a DB Writer between Homeseer and InfluxDB, I use it to pull weather from DarkSky, I have one as a 1W interface, etc. etc. so there's a lot of usages for it.

    The Package is this:

    The nice thing about this package (which uses this package for Alexa functions) is that all the functions are easily accessed.
    you can set up an event trigger that reports all events (i.e. if you tell Alexa to do something it will trigger an event that contains all the information about what just happened so you can capture it and build actions based on said events).

    It has a built in proxy-login and generates it's own cookie if you use it, or you can enter the cookie manually once captured (easier that way if you do a lot of debugging since you have to enter your credentials every time you deploy your NodeRed settings).

    You can issue different speak/TTS commands, "Speak" as the name applies had Alexa saying the text you send, "Announce" does the same thing but adds the dingdong notification (and only to the device you specify). If you don't specify a device, it will speak/announce on all devices automatically (no need for groups).
    You can utilize Amazons SSML ( so that you can change the way Alexa speaks (faster, slower, different pitch, volume, etc.) What I find "coolest" is that you can have her Whisper.
    You can issue speak with volume commands so that it sets the device to a certain volume, says whatever it was you wanted it to say and then restores the previous volume,
    this does not work for automatic "ALL" but it's useful for individual devices.

    There's a home automation branch as well that I haven't had a chance to dig into, but the TTS portion alone is great.

    I have a flow set up that reads MQTT commands from HomeSeer, so I can issue these... as an example...

    Alexa/Announce/ALL=Good Morning Announces to All Devices
    Alexa/Announce/Office=Good Morning Announces in Office
    Alexa/Speak/Office=Good Morning Speaks in Office
    Alexa/Whisper/Office=Good Morning Whispers in Office
    Alexa/Announce/Office/100=Good Morning Announces in Office w. volume set to 100

    Here's two different flows:

    MQTT to Alexa.txt

    If you prefer webhooks over MQTT you can create an event to run a script in HS:

    &hs.URLAction("http://IPofNodeRed:1880/HS4?Action=Announce&Where=Office&Volume=20&SayWhat=Testing%2 0Testing", "GET", "", "")

    WebHook to Alexa.txt
    Attached Files

    Well mr.Magoo now you have sparked my interest. I have all the gear setup as you described but need help with what should be the simplest part. Authenticating my Alexa account.

    Everything I try seams to fail.




      1-5 for simple login (but you have to login every time you deploy) , 1-7 to grab the cookie

      You might have to change the host/page depending on what you guys use down under.

      Add this flow

      1. Double click the Alexa Init / Refresh node and give it a name, and update the account settings (pen)

      Click image for larger version  Name:	1.PNG Views:	0 Size:	17.4 KB ID:	1321197

      2. Change the IP to the IP of your device, if you're on a machine where you have a local webbrowser you can leave it as blank/local host but if you need to access it from another device you need to enter the IP it should listen from / bind to.
      Click image for larger version  Name:	image_81173.png Views:	3 Size:	40.0 KB ID:	1321195

      3. Point your browser to your IP :3456 and it'll open up the alexa login
      Click image for larger version  Name:	3.PNG Views:	0 Size:	15.7 KB ID:	1321193

      4. Login (it'll say "Amazon Alexa Cookie successfully retrieved. You can close the browser." when done
      Click image for larger version  Name:	image_81180.png Views:	3 Size:	47.6 KB ID:	1321202

      5. There appears there's a bug so the cookie gets "lost" from the debug window the first time, so once the status says "ready" you can insert and have it refresh the cookie

      Click image for larger version  Name:	5.PNG Views:	0 Size:	15.1 KB ID:	1321196

      6. Open the debug window and copy everything in the Local Cookie string (between the " ")
      Click image for larger version  Name:	6.png Views:	0 Size:	18.1 KB ID:	1321194

      7. Create a new account and set the method to Cookie and paste your cookie into the cookie field
      Click image for larger version  Name:	image_81181.png Views:	3 Size:	26.3 KB ID:	1321203


        Hi mr.Magoo, Thank you for the detailed instruction, I would never have got there without this help.

        Ok here is where i'm up to. Basically I'm now stuck on step 3. I get the open xxx in your browser. but the Browser will not open the page. I have tried on numerous computers win10 (using different browsers) rpi, and ios safari. even tried to open port 3456 to the Alexa. I'm running a Unifi network and also tried turning off the firewall. is there another way to get this cookie info in there?


          Did you change the ip and the ip listed when it says "open... :3456" matches that of your node red device

          The ip is the ip of the device running node-red, not your alexa device.


            Thanks that was spot on, advanced to the next stage. Completed the amazon login. got the "ready" status but nothing but an error in debug.

            TypeError: failed to initialise smarthome colors: "Cannot read property 'parameters' of undefined" at AlexaRemoteExt.initSmarthomeColorsExt (/home/pi/.node-red/node_modules/node-red-contrib-alexa-remote2/lib/alexa-remote-ext.js:307:35) at process._tickCallback (internal/process/next_tick.js:68:7)


              Disregard the error, it's a part of the bug I'm talking about in #5 (FWIW, I'm NOT the developer of any of the packages)

              Does the Node say "Ready" ?
              Click image for larger version

Name:	ready.PNG
Views:	4777
Size:	13.7 KB
ID:	1321264

              Technically you're done at that point and if you have other Alexa-Nodes using the same account/login method they should all be "ready" and you can start to test it,

              The Cookie (which I still recommend using, at least during the debug/test phase) is only to make life easier during debug.


                Finally some success, thank you for your patients and support.

                I must say even though its still a work in progress it does work very well.

                I had some mixed success with the flow you presented. Mostly it worked, and better than I could have done on my own.

                I have two devices. and the Announce/All did not work at all. I was able to post a Alexa/Announce/Office (using my device name instead of Office) but did not get the Chime, sounded the same as Speak. all the others where the device name was specified worked ok (except the announce chime)

                For what I need its working very well. Now hopefully they can fix the cookie bug to make this even better.


                  The bug isn't related to the cookie, it just happens to affect the debug log that way.... but yes, its work in progress and both developers have been very helpful and fast to fix any issues.

                  It's odd that yours doesn't work the same as mine, but that might be down to my parse which is pretty crude.
                  Which mqtt plugin do you use to send the messages ?

                  For fun, try and add a routine node and manually configure it to announce and what to say and just use a single inject to trigger it (to rule out mqtt/parsing).
                  If you leave the device (in the node settings) as an empty string it should announce to all.

                  My parse requires you (I think, can't verify right now) to name it ALL (all caps), if you do "All" it won't work.


                    I use the MQTT Lens software, its a Chrome plugin. Using "ALL" in the Announce. also tried using MQTT from HS3 still no difference. Really puzzling, but not a show stopper.


                      Click image for larger version

Name:	Capture.PNG
Views:	4687
Size:	7.5 KB
ID:	1322541

                      I've used Lens for debugging a few times so I'm familiar with it - using this setting works for me.
                      If you enable the debug flags in NodeRed it should hopefully tell you what's going on.


                        I got to this to work! Have you messed with the SSML modes any? I would like to use the the whisper mode but haven't had any luck.



                          Yes I'm using it, my flow (posted in the first post) should work with Whisper if you send it as:
                          Alexa/Whisper/Office=Good Morning

                          Or - if you're using some other method, just use a function to alter the message:

                          msg.texttospeak = '<speak><amazon:effect name="whispered">' + msg.texttospeak + '</amazon:effect></speak>';

                          return msg;

                          The only thing that doesn't work right now (sadly) is to play stored media, i.e. sound effects etc. Theoretically you should be able to do that with SSML too, but it doesn't work just yet. Playing regular music as normal with Alexa works just fine.


                            Just tested it and it works fine...

                            I you do anything by volume and get an "unexpected response while getting volume:" then that's thrown me off in the past.

                            What the code does is that it will first read the current volume, then set the desired volume, do whatever it is you're asking it to do (speak, announce, whisper...) and then restore the volume back to the original setting.

                            However, the part where it is reading the current volume is reading a section of the media handling and if you haven't played any media in a while it's "forgotten" and everything is blank and as a result the Node gets a bit upset... the quick and dirty way to remedy this is to simply have Alexa play some tunes for a second or two so that her memory gets restored.


                              Originally posted by View Post
                              I got to this to work! Have you messed with the SSML modes any? I would like to use the the whisper mode but haven't had any luck.

                              I'm able to have alexa speak by manual triggering it in node-red but not having any luck through mqtt. I setup a mqtt input and i can see it in the debug messages but i cant pass or trigger tts. Any advice?

                              new to node-red and somewhat new to mqtt.