Alexa Announce Feature - Text to Speach via Alexa now a possability?

Noticed an odd issue with this process vs the medial player TTS alexa.

I have an automation that tells me it’s time to leave for work. This is the body of the message

          Based on current traffic, you have 15 minutes to leave if you want to get to khaki by 8:30am.  Traffic is {{ states('sensor.pauls_traffic_density_to_caci') }} today.

What it says is

30am.  Traffic is {{ states('sensor.pauls_traffic_density_to_caci') }} today.

It does say the state, so it’s really

30am.  Traffic is normal today.

Seems like it does not like the colon. I could spell it out, but would prefer to figure out the best way to handle this. Maybe it needs to be surrounded in quotes “”. I just noticed this this morning on my way to work, so have not had time to test various options.

there is no use for things like : . , etc.
what you are using is the “simon says” skill and that skill doesnt know those things.

you can test every sentence you want her to say by saying

alexa simon says your sentence

and then look in the history how she did write it down.

Totally understand. I’m just letting people know that things like time with a colon may not play correctly. The script is not passing the whole message when there is a colon. It’s not an Alexa Simon says issue. But as you say it’s not hard to work around it if you are aware of it.

1 Like

On a side note, this has helped me to realize I need to update my automation anyway. I now have an input_datetime I use for my work time, so that the automation is more customized. So having 8:30 as text is not really always true.

I’ll have to do some testing but I wonder how it will handle a state that includes a colon.

such as this

Based on current traffic, you have 15 minutes to leave if you want to get to work by {{ states('input_datetime.work_time') }} .  Traffic is {{ states('sensor.pauls_traffic_density_to_work') }} today.
1 Like

Just following up on my own thread. If you look through the script that actually does the work, this looks like the section that parses the text for simon says

	speak:*)
			SEQUENCECMD='Alexa.Speak'

			TTS=$(echo ${COMMAND##*:} | ${SED} -r 's/[^-a-zA-Z0-9_.,?! ]//g' | sed 's/ /_/g')
			TTS=",\\\"textToSpeak\\\":\\\"${TTS}\\\""

I’m not a programmer, but I see the colon. Maybe that’s where it see’s the colon and breaks up the message. I know the Alexa as a media player did not have an issue with my text that included the colon, so i assume it either has handling for the colon,or just formats the TTS differently.

Really not expecting a change to the script, just passing along what I see

I just wanted to report back that

{{ states('input_datetime.work_time') }}

does not speak correctly either. The script cuts it off at the colon as well. Does not matter if I wrap it in quotes or not. In order to read a time variable, I’ll have to parse it into plain language. That will be kind of a pain. I’d say this is a “bug”, but not one that could not be worked around.

The Media player TTS does not have this issue, but I’m very happy with this script so I’ll have to work around the issue at the moment.

I posted a question since the answer on how best to parse this out in YAML would probably be useful other places as well

Using the IDs does work. There are 1000’s of IDs of course, and probably not the easiest to use the script to find them. Anyone know an easy way to get the amazon station or playlist ID another way?

Not the Easiest, but using a browser (music.amazon.com), found a station, clicked share Station, and then copied URL, it was obvious what the station ID is. I’m sure you could so that with playlists, artists, etc.

For me this is just fine, I dont plan on doing this a whole lot. Would be more of an automation to start a station when I get home or something similar.

EDIT: Easiest option so far. Create a routine to play music. Pick the song, artist, playlist, etc. Choose your music provider such as Pandora, Spotift, amazon, siriusxm, etc, and save the playlist, then call the playlist using the script.

I created a routine called “music music music” called is like so:

alexa_remote_control.sh -e automation:‘music music music’

The routine does require you to select the echo you want or I suspect it will just default to your default echo.

Actually now that I have fully moved over I realize it’s a bit more of an pain than I realized. I have several automation based on people arriving or leaving a location. Since these dont go off all the time I did not realize until tonight.

Stuff like
Person X left “Zone name” at TIMESTAMP , and will be home in X minutes.

Now I’m just getting for example (left at 6:45)
45, and will be home in X minutes.

in your automations you could use

regex_replace(string, find=’:’, replace=’ ', ignorecase=False)

but i just tried and changing : to :: in the script also works i believe
in this line:

			TTS=$(echo ${COMMAND##*:} | sed -r 's/[^-a-zA-Z0-9_,?! ]//g' | sed 's/ /_/g')

after COMMAND##*

off course you need to change your command to

-e “speak::‘test 12:45’”

Adding the :: to the script kind of worked. Spoke time as numbers. Of course not like a time, but that can be worked. Only issue was when I spoke a sentence that started with a time stamp it added the word “speak” even though it was not in my automation. On my request for formatting, I got some good recommendations for better ways to provide the time without a colon that seems to be pretty good.

{{ as_timestamp (now()) | timestamp_custom('%-I %-M %p') }}

has worked well, I did not realize my timestamp_custom with the : was something i could change/remove.

Edit: I realized I forgot to add the second :: to the wrapper.sh script. That definitely solves the colon issue. Good deal! thanks again

OK, got it figured out. For Input_datetime, I just pulled the hour and minute attributes

ended up with this

Based on current traffic, you have 15 minutes to leave if you want to get to work by {{ states.input_datetime.work_time.attributes.hour }} {{ states.input_datetime.work_time.attributes.minute }}

Worked great, still have to figure out how to get it to speak leading 0’s better.

Right now, 8:30 speaks perfect,
8:05 says
8 5
8:00 says
8 0

Hey, just wanted to say, thanks for this. Set this up today and it worked 1st time. I created an automation to set the volume of my echos like so

  action:
  - service: shell_command.alexa_vol
    data_template:
      device: office
      volume: 30

This is really probably more of a yaml question, but is there an easy way to set the volume of multiple echos at once. I was thinking it might be a nice way to reset the volume of my echos on a regular basis. or maybe better use would be to max out all the volumes before sending an alert, like smoke detector warning, etc.

1 Like

I created this shell command to automate a routine:

sono_a_casa: sudo /home/homeassistant/.homeassistant/./alexa_remote_control.sh -e automation:"Alexa, sono a casa" -d "Echo Spot"

But it doesn’t work… i suppose the shell command must be inside quotes but don’t know which ones and how to put quotes… Any help?

This is the error i get:

Error running command: `sudo /home/homeassistant/.homeassistant/./alexa_remote_control.sh -e automation:"Alexa, sono a casa" -d "Echo Spot"`, return code: 1

NoneType: None

Try:

sono_a_casa: sudo /home/homeassistant/.homeassistant/alexa_remote_control.sh -e automation:“Alexa, sono a casa” -d “Echo Spot”

It’s what i have in shell_command… all without quotes…

Suddenly i get this from alexa_control.sh script:

ERROR: Amazon Login was unsuccessful. Possibly you get a captcha login screen.

 Try logging in to https://alexa.amazon.it with your browser. In your browser

 make sure to have all Amazon related cookies deleted and Javascript disabled!

But i don’t get any captcha login screen and i can visit the alexa.amazon.it with my account, but if i disable javascript cannot access anymore.
How to get the script working again?

Check for your cookie file. I suspect it is not there.

No, there is not anymore there… in /TMP i have only .alexa.login, but till this morning the script was working and the cookie file was there.
EDIT: i got the captcha, and succesfully accessed to alexa.amazon.it, but the script continue to send me that error…

If you restart your pi or sever the tmp directory gets cleared. The cookie gets deleted as well. You’ll need to get the cookie file again and put it in the tmp directory. It won’t won’t without the cookie