Skip to content
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

bugfix: on_end race condition / Speaker buffer full #36

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

cowboyrushforth
Copy link
Contributor

@cowboyrushforth cowboyrushforth commented Apr 17, 2024

"on_end" appears to be called before "on_tts_stream_end" usually this is fine because the previous yaml would wait for the speaker to stop playing to continue. but if the speaker has not started playing in the 500ms delay, then you get a race and we try to end before we actually start outputting audio

this can cause the system to become unstable, and output "Speaker buffer full, trying again next loop" over and over and over again for a long time.

tested with esphome 2024.04

…_tts_stream_end"

usually this is fine because the previous yaml would wait for the speaker to stop playing to continue.
but if the speaker has not started playing in the 500ms delay, then you get a race and we try to end
before we actually start outputting audio.

it appears for our use case that on_tts_stream_end solves this nicely and we dont have to put the artificial 500ms delay in anymore.
@cowboyrushforth cowboyrushforth changed the title on_end race condition / Speaker buffer full bugfix: on_end race condition / Speaker buffer full Apr 17, 2024
@tetele tetele added the bugfix Inconsistencies or issues which will cause a problem for users or implementors. label Apr 17, 2024
@tetele
Copy link
Owner

tetele commented Apr 17, 2024

Very good catch, thanks!

I can't test at the moment, but it seems like a very logical change, I'll merge it as is

@tetele tetele merged commit ff1e273 into tetele:main Apr 17, 2024
1 of 2 checks passed
@cowboyrushforth cowboyrushforth deleted the mww_fix_tts_race_condition branch April 18, 2024 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Inconsistencies or issues which will cause a problem for users or implementors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants