Line breaks in a conversation_response cause a pause in voice

I’ve been using Whisper and Piper for STT and TTS until today when I signed up for a Home Assistant Cloud trial. Previously, I’ve composed my conversation_response code like this (to make it easier to read and debug):

    - set_conversation_response: >-
        The bedroom lights have been set to 
        {% if trigger.slots.level == 'low' %}
          {{ states('input_number.lighting_level_low') | round(0) }}
        {% elif trigger.slots.level == 'medium' %}
          {{ states('input_number.lighting_level_medium') | round(0) }}
        {% else %}
          {{ states('input_number.lighting_level_high') | round(0) }}
        {% endif %}
        percent.

That worked great with Piper, but after converting TTS to Home Assistant Cloud, I get pauses every time there is a line break. So for example, on the code above, I get:

The bedroom lights have been set to
< roughly one-second pause >
45
< roughly one-second pause >
percent.

In order to get it working correctly with HA Cloud, I have to make sure that all the parts of a sentence are on one line in the code, without any line breaks. Anyone know what’s going on, or if there is a way to address it in code?

It is a known issue for YAML when you try to format it to be human readable.
YAML have another set of start and end markers that solve it.
{{ becomes {{- and remove a newline before the marker, if it is there.
}} becomes -}} and remove a newline after the marker if it is there.
{% becomes {%- and remove a newline before the marker, if it is there.
%} becomes -%} and remove a newline after the marker if it is there.

1 Like

Ah - thanks very much! I had seen the “-” versions of markers before, but hadn’t yet researched what they actually did. That solved it. :grinning: Thanks again!

It’s interesting though that it worked the way I wanted to when using Piper, without needing the different start and end markers.