Announce text-to-speech on media player

This blueprint allows you to create an announce script for your dashboard that is pre-configured to a specific media player and text-to-speech engine.

It is meant to be added to your dashboard. When activated, it will ask the user for the message to play.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

This blueprint requires Home Assistant 2024.3 or later.

blueprint:
  name: Announce
  description: >-
    A script that announces a message on a media player using text-to-speech.
  domain: script
  input:
    text_to_speech_engine:
      selector:
        entity:
          domain: tts
      name: Text-to-Speech engine
    media_player:
      selector:
        entity:
          domain: media_player
          multiple: true
      name: Media Player

mode: queued

fields:
  message:
    selector:
      text:
        multiline: true
    name: Message
    description: The message to broadcast
    required: true

sequence:
- service: tts.speak
  data:
    media_player_entity_id: !input media_player
    message: "{{ message }}"
  target:
    entity_id: !input text_to_speech_engine
3 Likes

Thanks a bunch for the blueprint. Works great on the homepods but fails on the Amazon echos with the " having trouble accessing the simon says skill etc" since Alexa Media Player can’t use the same TTS service. That was after adding the external URL to Alexa media player - prior to that it errored out with Alexa telling me to add the external URL to Alexa Media Player. I am not the best with blueprints and thought to change things to work with the echo speakers but I hit a road block before the workday started and now its on the back burner.

Do we just need to use a different TTS engine?

Love this blueprint and having it from my dashboard, very cool! One suggestion I’d give is to send a volume as well. That may significantly complicate things (e.g. get current volume, set volume to the user-selected variable, send tts, reset volume to original) but could be a good QoL feature. I set this blueprint up for 8 of my sonos speakers around the house, and I know from some of my other automations that TTS can come through a lot quieter than I’d like if I’m trying to actually get someone’s attention. We usually listen to music at 10-20% volume, but TTS works best (i.e. isn’t too loud or too quiet) at something like 60%

Thanks for this blueprint.
What would be the best way to add an option to select which media player to cast the announce to inside the script?
So not have one script for each media player but just one script with the option to select where to cast to?
I tried it with a selfmade list but that just doesn’t look nice and fails when selecting more than one entry.
I tried it with entity but that gives me a huge list of all entities.
Add a media selector expects me to select media and not just the media player.

Any nice solutions here?

I did this a couple of years ago.

🧯 TTS Script Blueprint for All 11 HA Core TTS Flavors.

HA_Blueprints/Scripts/tts_All_Message_Script_Blueprint.yaml at c05d6fb431c1d84cb145c7d6dd5ffe5a60b1d9e2 · SirGoodenough/HA_Blueprints · GitHub.

It includes roll-your-own action sections for before and after so you can adjust volume, play a sound effect, notify your phone, or any other action.

Pardon my ignorance, but how do I add this to my dashboard?

2 Likes

Thanks! I’ve wondered about this type of thing before (kitchen to office notes, etc.

So far the kids and I have had fun with it.

Thanks for this!

How would I modify it to select a minimum volume of the message?
Sometimes I lower the volume real low at nights in the kids room, but then next morning they don’t hear it at all when I message.

Same question please
I’ve been looking into this - I send TTS to Alexa in a very different way (no TTS engine installed, so this blueprint won’t work), but I’d still like to know how you add this to the dashboard with a Run button and multi-line message entry!

Thank you

1 Like

In case anyone comes here looking for similar…

I created a card
image

Code is below… I trigger it with an input boolean then trigger announcements using node red

Maybe help someone

type: custom:vertical-stack-in-card
cards:
  - type: entities
    entities:
      - entity: input_text.alexa_announcement_string
        name: Alexa Announcement
        icon: mdi:home-sound-out-outline
        secondary_info: none
    show_header_toggle: false
    state_color: false
    card_mod:
      style: |
        ha-card {
          border-radius: 100px!important;
        }
  - type: custom:mushroom-select-card
    entity: input_select.alexa_announcement_room_selector
    fill_container: false
    layout: horizontal
    primary_info: none
    secondary_info: none
    card_mod:
      style: |
        ha-card {
          margin-top: -10px;
          margin-right: 60px;
          margin-bottom: 10px;
        }
  - type: custom:mushroom-chips-card
    card_mod:
      style: |
        ha-card {
        float: right;
        padding-right: 14px;
        margin-top: -58px;
        }
    chips:
      - type: action
        tap_action:
          action: perform-action
          perform_action: input_boolean.turn_on
          target:
            entity_id: input_boolean.alexa_announcement_toggle_for_dashboard
        icon: mdi:send
        card_mod:
          style: |
            ha-card {
              margin-left: auto;
              margin-right: 0px;
              margin-bottom:5px;
              --chip-background: {{ '' if is_state('input_boolean.alexa_announcement_toggle_for_dashboard', 'off') else 'rgba(166, 207, 152, 0.5)'}};
              padding: 0px;

              #rotate: -30deg;
              justify-content: right;
              --chip-height: 40px;
              --chip-border-radius: 100%;
              --chip-icon-size: 20px;
              animation: ping 2s infinite;
            }
            @keyframes ping {
                0% {box-shadow: 0 0 0 0 rgba(var(--rgb-blue), 0.7);}
                70% {box-shadow: 0 0 0 10px transparent;}
                100% {box-shadow: 0 0 0 0 transparent;}
            }