Jingle before TTS

Hello, I have succesfully configured TTS using google_translate platform. Is there some way how to play “jingle” (just s short sound) before selected messages?
Thank you.

Sure, stick a “jingle” in your www/ folder (see here) and then use a media_player.play_media service call before your TTS call, like this:

  - service: media_player.play_media
    data:
      entity_id: media_player.WHATEVER
      media_content_id: https://myhost.dynamic.dom:12345/local/jingle.mp3
      media_content_type: music

I found someting like:
action:
- event: chime_tts
event_data_template:
entity_id: all
sound: airplane-cabin-ding-dong.mp3
message: “We don’t live in a barn. Close the {{ trigger.to_state.name }} door.”

But is there some way how t let “ding dang” to be interpreted by google service? Some special word or easter egg which is not translated but played maybe? :smiley:

OK, so you mean as DING_ACTION before TTS_ACTION right? And I should set some delay to my TTS_ACTION to wait until DING_ACTION is played. Right?

btw: what should be the path to media? I use /tmp/tts in google tts config but there are no sound files there or maybe I search in a wrong path… (because it works)

What is in fact this http://ip:port/something path in raspbian?

The path for the media, has to be under www/ in your config folder - see the docs I linked to previously

No, because you’re just playing an MP3 to your device, no Google Service involved.

Yes, and possibly - it’ll depend on how long it takes to play that MP3 and then generate the TTS

Yes, thank., you are right there is it described. To create WWW folder there where YAMLs are and restart HA.

Yet another question @Tinkerer - what if I have multiple G home´s?

How to play to single is OK, no problem. But how to do it if I want to play TTS or MUSIC to multiple or all at once (without delay)?

put all GH’s in a group (call that ‘broadcast’ if you like :wink: ) and play to that group.

Good idea - with groups. Will try. And how about volume? If it happen that somebody turned Google home to Volume 0 or 1 the voice will be hardly hearable.
Is it possible to send command to turn volume to specified amount together with TTS?

sure, this is part of my scripting engine taking care of all of that:

      - service: media_player.volume_set
        data:
          entity_id: >
            {{states('sensor.intercom')}}
          volume_level: >
            {{states('input_number.intercom_volume')|float}}
      - service: tts.google_say
        data:
          language: >
            {{states('input_select.intercom_language')|lower}}
          entity_id: >
            {{states('sensor.intercom')}}
          message: >
            {{states('input_select.intercom_message')}}

hmm, not working:

> - id: '1602057758939'
>   alias: tts-terasa
>   description: ''
>   trigger:
>   - entity_id: switch.sonoff_1000e2cd1a
>     from: 'off'
>     platform: state
>     to: 'on'
>   condition: []
>   action:
>   - data:
>       media_content_id: http://192.168.1.15:8123/local/media/Airplane-ding-dong.mp3
>     entity_id: media_player.living
>     service: media_player.media_play
>   - data:
>       entity_id: media_player.living
>       language: cs
>       message: My message.
>     service: tts.google_translate_say

with error:
Logger: homeassistant.components.automation
Source: helpers/script.py:693
Integration: Automatizace (documentation, issues)
First occurred: 12:21:23 (6 occurrences)
Last logged: 12:24:38

tts-terasa: Error executing script. Invalid data for call_service at pos 1: extra keys not allowed @ data[‘media_content_id’]

OH, should be: media_player.play_media

yes, ws just posting this:

  sound_bite:
    alias: Sound bite
    mode: restart
    sequence:
      service: media_player.play_media
      data:
        entity_id: >
          {{states('sensor.sound_bite_player')}}
        media_content_id: >
          {{states('sensor.sound_bite')}}
        media_content_type: music

Yes.

You have read the docs for the media_player integration? They’re right here if you missed them.

1 Like

I am trying to modify my current automation for notification of messages at the end of a condition, but although I have added the lines you described with the appropriate changes to my addresses, the result remains unchanged.
The notification arrives but the jingle does not play, I do not understand where I am wrong.
Below the lines used:

  action:
 
  - data_template:
      message: Il microonde primo piano ha terminato!
      title: Casa
    service: notify.notify

  - service: media_player.play_media
    data:
      entity_id: media_player.mini_tutti
      media_content_id: https://myduckdnsaddress:myport/local/airplane-ding-dong.mp3
      media_content_type: music

  - service: tts.google_translate_say
    entity_id:  media_player.mini_tutti 
    data:
      message: "Il microonde al primo piano ha terminato!"                      

I suspect that no sooner has the ‘ding-dong’ been sent to the media player, the TTS gets sent.

Try putting a delay after the ding dong.

O r better yet wait for the state of the media player to change to playing and then to paused.

1 Like

Exactly what klogg said:

  1. Send the ding-dong
  2. Pause for a second (so that the change of state can be detected by HA)
  3. Wait for the state to become idle
  4. Send the TTS

Thank you for for the replies.
Later on returning home I will try.
To understand, should I put a generic pause of even 0.5 seconds or should I put a pause identical to the duration of the running mp3?