Skip to content

Snapcast: TTS and local files do not play to the end #2690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
rich33584 opened this issue Jul 27, 2024 · 62 comments
Closed
1 task done

Snapcast: TTS and local files do not play to the end #2690

rich33584 opened this issue Jul 27, 2024 · 62 comments
Assignees
Labels
bug Something isn't working Fix to be Confirmed related Issue is related to other issues (solve combined) Snapcast

Comments

@rich33584
Copy link

What version of Music Assistant has the issue?

2.1.0

What version of the Home Assistant Integration have you got installed?

2024.6.2

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

  • Yes

The problem

TTS and local files stop early. They only play about 75% and then stop . Files less than about 4 seconds do play to the end.

How to reproduce

You can reproduce by going to the integration and selecting a player. Browse media, then either play a local file or choose text to speech. Type in a message or play a local file that will be at least 5-6 seconds. It will stop before the entire file/message has played.
Video showing tts:
https://youtube.com/shorts/rj-SRbg7wfc?feature=share

Music Providers

Local files/TTS
Radio does not stop.
Spotify plays tracks to the end.

Player Providers

Snapcast
I have not tried other players but will try a chromecast player later and report back.

Full log output

music-assistant.log

Additional information

No response

What version of Home Assistant Core are your running

2024.7.3

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Generic x86-64 (e.g. Intel NUC)

@rich33584 rich33584 changed the title TTS and locl files do not play to the end TTS and local files do not play to the end Jul 27, 2024
@OzGav
Copy link
Contributor

OzGav commented Jul 27, 2024

Can you provide the exact steps in detail that you are using as it looks from the video that you are doing something unusual.

I don't know why you are using Piper to generate the TTS and I don't know why it looks like you are sending to a voice satellite? Hard to tell what I am seeing in the video though.

@rich33584
Copy link
Author

Can you provide the exact steps in detail that you are using as it looks from the video that you are doing something unusual.

I don't know why you are using Piper to generate the TTS and I don't know why it looks like you are sending to a voice satellite? Hard to tell what I am seeing in the video though.

In the video, I go to the integration. Select a player then browse media. From there go to text to speech. Enter a message that will be about 5-6 seconds and play the message

@OzGav
Copy link
Contributor

OzGav commented Jul 29, 2024

I cannot reproduce this. Please try with a different player and let us know how you go.

@rich33584
Copy link
Author

I cannot reproduce this. Please try with a different player and let us know how you go.

Chromecast does operate properly. So just seems to be a Snapcast player issue.
I dont have any other players to test with.

@OzGav
Copy link
Contributor

OzGav commented Jul 29, 2024

@SantiagoSotoC I wasn’t able to replicate this with my Snapcast setup. Any ideas?

@SantiagoSotoC
Copy link
Member

I didn't try it now, but I remember some of this but it was when tts support was added, I can add a little delay when a ttl is finished playing, so it doesn't change stream so fast.
@rich33584 you can try changing the buffer size and see if that affects the duration of the tts

@rich33584
Copy link
Author

rich33584 commented Jul 31, 2024 via email

@SantiagoSotoC
Copy link
Member

But there was no change? Increasing does not worsen the problem ?

@rich33584
Copy link
Author

But there was no change? Increasing does not worsen the problem ?

No, The longer the file, the longer it plays. To about 75% completion. Maybe its reporting the caching of the file as finished playing? I dont know if I am explaining what I am thinking correctly...Maybe as the file is being transferred to the device its reporting the finished transfer as finished playing? This is nowhere near my area of expertise...

@OzGav OzGav added the Snapcast label Aug 1, 2024
@OzGav
Copy link
Contributor

OzGav commented Aug 1, 2024

Please explain exactly how you are playing the music files. Also detail how your HA and MA installation is setup as well as information about your network setup. No one else is reporting this problem.

@rich33584
Copy link
Author

rich33584 commented Aug 1, 2024 via email

@OzGav
Copy link
Contributor

OzGav commented Aug 1, 2024

OK there is no working solution for a combined voice satellite and media player to my knowledge

@OzGav OzGav removed the Snapcast label Aug 1, 2024
@rich33584
Copy link
Author

rich33584 commented Aug 2, 2024 via email

@OzGav
Copy link
Contributor

OzGav commented Aug 2, 2024

Ok we will close this. If you find more info to suggest something in MA is broken we can reopen

@OzGav OzGav closed this as completed Aug 2, 2024
@rich33584
Copy link
Author

rich33584 commented Aug 2, 2024 via email

@SantiagoSotoC SantiagoSotoC reopened this Aug 15, 2024
@SantiagoSotoC
Copy link
Member

This does happen, I just tried to use piper and google ttl from ma and it only reprocesses the beginning.

@rich33584
Copy link
Author

rich33584 commented Aug 15, 2024

Ok, I was about to install HA on a PI so I could test and see if there was something in my installation causing this. Ill hold off.
Have you tried a local file? Going into the MA integration and playing it from there?
BTW, I have tried several versions of snapcast on the player with the same effect. Even an old config that was working a few weeks ago.

@SantiagoSotoC
Copy link
Member

Only with the ttl from ha, I didn't test a local file, but it should be the same. it's not a snapcast problem, it's most likely because of how we handle the pause. I assume that if ffmpeg ends snapcast ends, we would have to add a delay, at least for that kind of files

@rich33584
Copy link
Author

Thanks for continuing to look into this. I greatly appreciate it.

@OzGav OzGav removed the More info label Aug 20, 2024
@SantiagoSotoC
Copy link
Member

Well, @whc2001 you can test it now, the problem of short tts is still there but it is a very special use case, most probably it will be fixed, looking for the ideal value of the idle_threshold and updating the state with a callback as it was done before

@whc2001
Copy link

whc2001 commented Oct 2, 2024

Well, @whc2001 you can test it now, the problem of short tts is still there but it is a very special use case, most probably it will be fixed, looking for the ideal value of the idle_threshold and updating the state with a callback as it was done before

Got it, I just realized there is a mistake in the original code, fixing it right now

@whc2001
Copy link

whc2001 commented Oct 2, 2024

@SantiagoSotoC Does this look good to you? Haven't tested it yet gonna do it later
https://github.com/whc2001/server/commits/snapcast_add_idle_threshold/

@SantiagoSotoC
Copy link
Member

It lacks some things, if you want to do the pr and I finish it

@whc2001
Copy link

whc2001 commented Oct 2, 2024

It lacks some things, if you want to do the pr and I finish it

Great thanks!
music-assistant/server#1691

@OzGav
Copy link
Contributor

OzGav commented Oct 18, 2024

@SantiagoSotoC @whc2001 Can this be closed or are you waiting for it to get to stable?

@whc2001
Copy link

whc2001 commented Oct 18, 2024

@SantiagoSotoC @whc2001 Can this be closed or are you waiting for it to get to stable?

I don't seem to have the permission to close it

@OzGav
Copy link
Contributor

OzGav commented Oct 18, 2024

I will close it if you tell me it is fixed!

@whc2001
Copy link

whc2001 commented Oct 18, 2024

I will close it if you tell me it is fixed!

Ah got it, I think maybe wait until it's released and tested a bit?

@OzGav
Copy link
Contributor

OzGav commented Oct 19, 2024

Beta 30 has been released.

@OzGav
Copy link
Contributor

OzGav commented Oct 20, 2024

@rich33584 Are you able to check if this is fixed in the beta?

@rich33584
Copy link
Author

@rich33584 Are you able to check if this is fixed in the beta?

The automations with TTS are working good. For some reason I cant get anything to work when choosing the player in the integration and going to Browse Media. It just instantly goes to Idle.
The TTS automations are way more important to me and they are working good. Thanks.
Maybe the other issue is on my end..
player

@SantiagoSotoC
Copy link
Member

@rich33584 Are you able to check if this is fixed in the beta?

The automations with TTS are working good. For some reason I cant get anything to work when choosing the player in the integration and going to Browse Media. It just instantly goes to Idle. The TTS automations are way more important to me and they are working good. Thanks. Maybe the other issue is on my end.. player

The text is long ? short TTS are still a problem.

@rich33584
Copy link
Author

After further testing, the clips need to be around 5-6 seconds long and they play fine. Shorter ones are still an issue as you said.
Not sure if that would be an issue in real world use anyway.
Thanks!

@whc2001
Copy link

whc2001 commented Oct 20, 2024

@rich33584 Are you able to check if this is fixed in the beta?

The automations with TTS are working good. For some reason I cant get anything to work when choosing the player in the integration and going to Browse Media. It just instantly goes to Idle. The TTS automations are way more important to me and they are working good. Thanks. Maybe the other issue is on my end.. player

The text is long ? short TTS are still a problem.

I tested the latest main branch and things are working for me at least. The release time after TTS has finished is a bit long to my liking but that's off topic.

EDIT: Tested with Snapclient WebUI and it does not work at all. Each time the source is switched the web client is stuck until refreshed. Something is definitely still problematic...

f94b7c316a009f4c46a0fc48701c27ae.mp4

@marcelveldt marcelveldt changed the title TTS and local files do not play to the end Snapcast: TTS and local files do not play to the end Oct 20, 2024
@marcelveldt
Copy link
Member

marcelveldt commented Oct 20, 2024

While I was doing some tweaks for TTS yesterday I could 100% reproduce this issue with snapcast players.
Short audio clips (TTS or something else) simply do not play. I think its safe to assume this is a snapcast limitation.

@OzGav
Copy link
Contributor

OzGav commented Oct 20, 2024

I have added a note to the docs about short announcements

@SantiagoSotoC
Copy link
Member

About snapweb an issue has been opened in their repo, it may take a while to fix it.
badaix/snapweb#108

@SantiagoSotoC
Copy link
Member

While I was doing some tweaks for TTS yesterday I could 100% reproduce this issue with snapcast players.
Short audio clips (TTS or something else) simply do not play. I think its safe to assume this is a snapcast limitation.

Adding a minimum time between creating a stream and destroying it does not solve the problem ?

@marcelveldt
Copy link
Member

Adding a minimum time between creating a stream and destroying it does not solve the problem ?

I didnt look further into it, I just notice dit while testing something else.

@OzGav
Copy link
Contributor

OzGav commented Oct 23, 2024

@rich33584 2.3.0rc1 is released. Please test again

@SantiagoSotoC
Copy link
Member

@rich33584 2.3.0rc1 is released. Please test again

Now even one letter should work

@rich33584
Copy link
Author

@rich33584 2.3.0rc1 is released. Please test again

Its working!
Thanks so much!
This was so much more involved than I had envisioned..

@OzGav OzGav closed this as completed Oct 24, 2024
@whc2001
Copy link

whc2001 commented Oct 24, 2024

Tested without any problem and seems like the delay after short announcement is partially mitigated. Thanks everyone! Looking forward for this to be released so I can finally uninstall the dev version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fix to be Confirmed related Issue is related to other issues (solve combined) Snapcast
Projects
Archived in project
Development

No branches or pull requests

5 participants