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

Bug fix: _play_speech get stuck due to orphan speech handle. #1555

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SiyuanQi
Copy link

@SiyuanQi SiyuanQi commented Feb 26, 2025

When a new _synthesize_answer_task is created, it is possible that the old _synthesize_answer_task is waiting for the llm_stream at

llm_stream = await llm_stream

In this case, the new task will cancel the old one. However, the handle of the old task is not correctly canceled.

This would result in the handle never being initialized by _synthesize_answer_task.

As a result, the _play_speech function will stuck at await speech_handle.wait_for_initialization(), and blocks all the subsequent speeches.

Note that the old handle is supposed to be canceled by self._pending_agent_reply.cancel() in the _synthesize_agent_reply function. However, this is not working properly since self._pending_agent_reply is assigned to None in the _validate_reply_if_possible function.

When a new _synthesize_answer_task is created, it is possible that the old _synthesize_answer_task is waiting for the llm_stream:
llm_stream = await llm_stream

In this case, the new task will cancel the old one. However, the handle of the old task is not correct cancelled.

This would result in the handle never being initialized by _synthesize_answer_task.

As a result, the _play_speech function will stuck at
await speech_handle.wait_for_initialization(), and blocks all the following speeches.

Note that the old handle is supposed to be cancelled by self._pending_agent_reply.cancel() in the _synthesize_agent_reply function. However, this is not working properly since self._pending_agent_reply is assigned to None in the _validate_reply_if_possible function.
Copy link

changeset-bot bot commented Feb 26, 2025

🦋 Changeset detected

Latest commit: 77047aa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-agents Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@davidzhao davidzhao requested a review from longcw February 27, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants