[solved with a 'repeat loop'] Extract summaries from todo.chores for TTS and pause between different items?

I’m trying to get the items on the chores (or shopping list) to be read by TTS.
It works but when there are multiple items, I would like to have a pause between them.
I have this:

service: todo.get_items
data:
  status:
    - needs_action
target:
  entity_id: todo.chores
service: tts.speak
data:
  options:
    voice: "voice"
  cache: false
  media_player_entity_id: "media_player"
  message: |-
    {%- for item in todo['todo.chores']['items'] %}
      {{ item.summary }}
    {%- endfor %}
target:
  entity_id: tts.piper

How do I add a pause in that loop?
TIA for any help!

the message template will get rendered and then sent to the media_player all at once when it’s fully rendered. so if you want to put pauses in there, there would need to be a pause marker in the tts. you could do things like ... and such, but you don’t get to control the specific wait time. and i don’t know of specific meta commands that piper supports. i would do something like the below.

i don’t know the format of the specific items you have but i think the framework you’re going to need is something like this… use repeat to call the tts multiple time with your specified delay between:

  - repeat:
      sequence:
        - service: tts.speak
          data:
            options:
              voice: voice
            cache: false
            media_player_entity_id: media_player
            message: |
              {{  repeat.item }}
          target:
            entity_id: tts.piper
        - delay:
            seconds: 5
      for_each: |
        {{todo['todo.chores']['items'] }}

1 Like

Hi armedad, thanks for helping!

This works, but… it reads the whole item so summary, UID & status, including these words themselves and of course the contents.

I’m not able to test it, but maybe this?

if this doesn’t work, please look at the trace and see what is in the variable repeat.item and paste it in here. we just need to parse out the right item… And how to do that depends on the structure of the contents of repeat.item

- repeat:
      sequence:
        - service: tts.speak
          data:
            options:
              voice: voice
            cache: false
            media_player_entity_id: media_player
            message: |
              {{  repeat.item.summary }}
          target:
            entity_id: tts.piper
        - delay:
            seconds: 5
      for_each: |
        {{todo['todo.chores']['items'] }}
2 Likes

Wonderful, this works!!! :star_struck: :bowing_man: :+1:

I did search some on if it could/how to solve this but couldn’t find anything and was also looking at the wrong part… :blush:

Thanks a lot!
I have a hunch that this topic might be used a lot in the future…

1 Like