core icon indicating copy to clipboard operation
core copied to clipboard

Media player does not go back to "idle" after playing TTS announcement

Open MacrosorcH opened this issue 7 months ago • 125 comments
trafficstars

The problem

On HA 2025.4.x, playing a TTS announcement via tts.cloud_say on a speaker running ESPHome (Raspiaudio Muse Luxe ~~and HA Voice PE~~) causes the media_player entity to remain stuck in status "playing" instead of going back to "idle" after audio playback is over. It worked well until HA 2025.3.4. Unless stopped manually, the same TTS announcement is played again on the speaker every 2 minutes, in a loop. In other words, the media_player stays in "playing" status forever and plays the same announcement repeatedly every 2 minutes, with silence in between and an audio glitch after each repetition (glitch that also wasn't there until HA 2025.3.4).

What version of Home Assistant Core has the issue?

2025.4.0b12

What was the last working version of Home Assistant Core?

2025.3.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Media Player

Link to integration documentation on our website

https://www.home-assistant.io/integrations/media_player/

Diagnostics information

No response

Example YAML snippet


Anything in the logs that might be useful for us?


Additional information

No response

MacrosorcH avatar Apr 01 '25 20:04 MacrosorcH

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (media_player) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of media_player can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign media_player Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


media_player documentation media_player source (message by IssueLinks)

home-assistant[bot] avatar Apr 01 '25 20:04 home-assistant[bot]

CC @synesthesiam

MartinHjelmare avatar Apr 02 '25 07:04 MartinHjelmare

The problem is still present on HA 2025.4.0 with Raspiaudio Muse Luxe running ESPHome 2025.3.3, i.e. the speaker media_player entity does not go back to "idle" status after playing a TTS announcement, and there is now also an audio glitch at the end of the announcement which wasn't there with HA 2025.3.4. The same problem is not present anymore instead on HA Voice PE running firmware 25.3.4 released today.

MacrosorcH avatar Apr 02 '25 18:04 MacrosorcH

Cc @tetele

MacrosorcH avatar Apr 02 '25 22:04 MacrosorcH

I found that, unless stopped manually, the same TTS announcement is played again on the speaker every 2 minutes, in a loop. So, the media_player is "playing" the same announcement repeatedly every 2 minutes, with silence in between... which I assume is why it never gets back to "idle" state. @synesthesiam Thanks for taking a look and happy to test or provide more information as needed.

MacrosorcH avatar Apr 03 '25 06:04 MacrosorcH

Я обнаружил, что, если не остановить вручную, одно и то же объявление TTS воспроизводится на динамике снова каждые 2 минуты, в цикле. Таким образом, media_player «воспроизводит» одно и то же объявление повторно каждые 2 минуты, с тишиной между ними... и я предполагаю, что именно поэтому он никогда не возвращается в состояние «неактивности». @synesthesiamСпасибо, что посмотрели, будем рады провести тестирование или предоставить дополнительную информацию по мере необходимости.

I have absolutely identical situation. Has anyone found a solution?

Vladd1980 avatar Apr 03 '25 07:04 Vladd1980

I am experiencing the same issue since 2025.4.0. When using TTS (With google or piper), the end of the sentence always have the same glitch, then the "Media Player" status stays in "Play" mode, and the sentence repeats after a handful of seconds, to infinite. "Media Player" never goes into "Idle" mode. Cache enabled or not doesn't change anything. Issue is NOT affecting the Tablet (fullykiosk), only the ESP32 based players (I2S Audio) in my case.

AnalogThinker avatar Apr 04 '25 00:04 AnalogThinker

@MartinHjelmare @synesthesiam Could you acknowledge this is a HA 2025.4.x issue or should we report it to the ESPHome team instead? Many thanks!

MacrosorcH avatar Apr 04 '25 16:04 MacrosorcH

@MartinHjelmare @synesthesiamМожете ли вы подтвердить, что это проблема HA 2025.4.x или нам следует сообщить об этом команде ESPHome? Большое спасибо!

I had this problem right after updating NA to 2025.4

Vladd1980 avatar Apr 04 '25 16:04 Vladd1980

I face the same issue after updating to 2025.4

BigHomie90 avatar Apr 04 '25 19:04 BigHomie90

After the latest Firmware update of the atom5 no sound output in the latest HA version.

Chris383838 avatar Apr 05 '25 13:04 Chris383838

The problem is still present in HA 2025.4.1.

MacrosorcH avatar Apr 05 '25 13:04 MacrosorcH

yep same here - this error makes this version of HA pretty unusable for my household.

alfwro13 avatar Apr 05 '25 16:04 alfwro13

There is an open issue for this problem also on ESPHome: https://github.com/esphome/issues/issues/6921 Still unclear whether this is a HA bug or a ESPHome bug.

MacrosorcH avatar Apr 06 '25 19:04 MacrosorcH

Some issue. ESPHome MediaPlayer with simplest configuration. looped announcement after use TTS.

shudashov avatar Apr 06 '25 21:04 shudashov

I have/had the same issue when I upgraded from 2025.3.4 to 2025.4.1.

I have about 8 esphome players around the house. When there was a house wide announcement all of the active lights on my players would stay lit. At random a single player would repeat the last house wide announcement until the next house wide announcement was played. All of the players are esp32 arduino framework players. Restarting ha would then close the channel and the players would go back to idle until the next house wide announcement (I don't have individual player announcements at the moment so I don't know if the issue carries over to a single player). The house wide announcements are sent to a media player helper group and not the individual media players.

Restarting the esphome service did not correct the issue. They continued to announce at random. Rebooting the players would also stop the announcement on that rebooted player.

Since this my wife approval factor was dropping quickly I rolled back HA core back to 2025.3.4 and everything became right again. I have an issue with recorder and several tasks that depend on it aren't running but at least the house isn't chattering all night. The only thing that was changed is me upgrading to 2025.4.1 and then rolling back the change several hours later to 2025.3.4. This kind of makes me think that something in at least 2025.4.1 has an issue because I can unissue it by putting it back to 2025.3.4

George1422 avatar Apr 07 '25 00:04 George1422

I have/had the same issue when I upgraded from 2025.3.4 to 2025.4.1.

I have about 8 esphome players around the house. When there was a house wide announcement all of the active lights on my players would stay lit. At random a single player would repeat the last house wide announcement until the next house wide announcement was played. All of the players are esp32 arduino framework players. Restarting ha would then close the channel and the players would go back to idle until the next house wide announcement (I don't have individual player announcements at the moment so I don't know if the issue carries over to a single player). The house wide announcements are sent to a media player helper group and not the individual media players.

Restarting the esphome service did not correct the issue. They continued to announce at random. Rebooting the players would also stop the announcement on that rebooted player.

Since this my wife approval factor was dropping quickly I rolled back HA core back to 2025.3.4 and everything became right again. I have an issue with recorder and several tasks that depend on it aren't running but at least the house isn't chattering all night. The only thing that was changed is me upgrading to 2025.4.1 and then rolling back the change several hours later to 2025.3.4. This kind of makes me think that something in at least 2025.4.1 has an issue because I can unissue it by putting it back to 2025.3.4

I can confirm this is also affecting single player/streamer. I did many individual tests (Developer tools -> Action -> TTS with a single ESPHome Player as a target) and issue was happening. Interestingly, playing a Radio does not generate any issue (probably because you have to STOP the stream instead of being stopped when it reaches the end of a length-defined audio stream such as a Chime MP3 or an audio block generated from TTS.

I have a feeling this could be an EOF or End-of-Stream issue, that would explain the glitch at the end, and potentially the reason why the backend deems necessary to re-stream if the end-device does not acknowledges integrity at the end of the audio stream reception.

AnalogThinker avatar Apr 07 '25 03:04 AnalogThinker

Image

Image

Image

Image

I found a temporary solution to the repetition problem.

I spent half a day looking for a way out of the repetition problem and found a pattern: if you play MP3 (I saved some messages as a cache in mp3 and play them via mp3) - there are no repetitions. If you play the text via TTS - the last message is repeated endlessly. You can stop repetitions only with the TTS command with the message content dot (".").

In my smart home I use Node RED, and I created a parallel command to play a TTS message "." after 5....10 sec (depending on the main message) after the start of playing the main message.

When the problem is solved - I will simply delete the parallel TTS command.

Maksys4101 avatar Apr 09 '25 16:04 Maksys4101

@Maksys4101 Your observation tracks with what I saw/heard. All of my TTS are played via a script that plays an announcement tone (mp3) before the tts is spoken. Thinking back I did not hear the announcement tone (mp3) as part of the repeat, it was only the spoken voice. I could turn off the light (payer would go to idle) if I sent the announcement tone via Developer tools.

George1422 avatar Apr 09 '25 20:04 George1422

I found a temporary solution with the info from the past few days here. But I use my device only for TTS announcements, so it might not work for all.

I have created an automation triggered by the start of playing of my tts speaker with a duration of 10 seconds and then stop the tts speaker.

WueBumbum avatar Apr 10 '25 16:04 WueBumbum

The problem is still present in HA 2025.4.2.

Maksys4101 avatar Apr 12 '25 16:04 Maksys4101

The problem is still present in HA 2025.4.2.

Yes. My experience is that it was caused by the HA upgrade from 2025.3 to 2025.4 Hope someone can fix this.

As a workaround, as suggested by @Maksys4101, I now play a very short mp3 at the end of my messages and then there is no repetition.

action: media_player.play_media

Jn115759 avatar Apr 13 '25 15:04 Jn115759

@MartinHjelmare @synesthesiam Hoping you had a chance to take a look, could you acknowledge the issue and confirm it will be resolved in an upcoming HA update? Happy to support in any testing/troubleshooting. Thanks!

MacrosorcH avatar Apr 13 '25 16:04 MacrosorcH

@MartinHjelmare @synesthesiam Hoping you had a chance to take a look, could you acknowledge the issue and confirm it will be resolved in an upcoming HA update? Happy to support in any testing/troubleshooting. Thanks!

Also prepared to help testing

Jn115759 avatar Apr 13 '25 18:04 Jn115759

For anyone looking for a temporary fix - this works... I found that if I pass it a template {{ text string }} then in doesn’t go back to idle, just loops over and over again. BUT, if I pass the same {{ text string }} to the custom component ChimeTTS (which adds a chime MP3 and send it to TTS) then it works fine. So for now I use a chime with all my TTS notifications. This approach solves the timing problem as you don’t need to know how long each one is.

glbailey avatar Apr 13 '25 23:04 glbailey

For anyone looking for a temporary fix - this works... I found that if I pass it a template {{ text string }} then in doesn’t go back to idle, just loops over and over again. BUT, if I pass the same {{ text string }} to the custom component ChimeTTS (which adds a chime MP3 and send it to TTS) then it works fine. So for now I use a chime with all my TTS notifications. This approach solves the timing problem as you don’t need to know how long each one is.

When you say to use ChimeTTS, are you talking about the integration from HACS?

RichardA1 avatar Apr 14 '25 23:04 RichardA1

This bug renders the Voice Assistant Preview Edition hardware useless and unresponsive after the media player function is used. The device needs to be unplugged and plugged back in to get it to work again--and even then I get some protests from the voice assistant about media player being on play and initial refusal to execute a spoken command, asking me if I'd like to stop the media player.

FortranFour avatar Apr 16 '25 20:04 FortranFour

The problem is still there with ESPHome 2025.4.0. :( Really looking forward to a solution.

MacrosorcH avatar Apr 17 '25 06:04 MacrosorcH

Hey all!

I am trying to reproduce this, but I cannot find a standalone, simple use case that makes the media player stuck at playing.

Here is what I tried, and my setup.

Home Assistant OS / core 2025.4.2 Voice Preview Edition, official firmware, not adopted on ESPHome Builder. Firmware: 25.3.4 (ESPHome 2025.3.3)

I went to the dev tool and tried 3 different actions that can all be used to perform announcements.

These are the exact action calls I used.

action: tts.cloud_say
data:
  cache: false
  entity_id: media_player.vpe_bureau_media_player
  message: TEST!
action: tts.speak
target:
  entity_id: tts.home_assistant_cloud
data:
  cache: true # I also tried false
  media_player_entity_id: media_player.vpe_bureau_media_player
  message: TEST!
action: assist_satellite.announce
data:
  message: TEST!
target:
  entity_id: assist_satellite.vpe_bureau_satellite_assist

I am also attaching a small video to show you that I cannot properly reproduce.

https://github.com/user-attachments/assets/d86fcf11-63d5-467f-9835-9c4f674b6c39

Can someone share a sample of the action call that makes the VPE media player stuck in playing please?

Thx a lot! JLo

jlpouffier avatar Apr 17 '25 08:04 jlpouffier

Hi Martin, I can't do a video but the screenshot shows that what you wanted.

Firing the TTS action causes the Player to go in a "playing" state and stay there until next reboot of the device:

Image

In the logs of the raspiaudio device I see this. With every yellow entry, the last sentence gets repeated

Image

Hope that helps.

Is it clear, where the problem is coming from? HA Core? Google TTS? ESPHome? Mediaplayer?

Bikestuff avatar Apr 17 '25 10:04 Bikestuff