Skip to content

Conversation

@MSameerAbbas
Copy link
Contributor

@MSameerAbbas MSameerAbbas commented Jan 30, 2026

Fixes issue where session.say() hangs when LiveAvatar is enabled. The _forward_audio loop now handles AudioSegmentEnd markers by calling notify_playback_finished, matching the pattern in AvatarRunner.

fixes #4668

Summary by CodeRabbit

  • Bug Fixes
    • Improved audio playback handling to properly manage completion of audio segments, reducing potential playback issues and ensuring correct state transitions.

✏️ Tip: You can customize this high-level summary in your review settings.

…ekit#4668)

Fixes issue where session.say() hangs when LiveAvatar is enabled.
The _forward_audio loop now handles AudioSegmentEnd markers by calling
notify_playback_finished, matching the pattern in AvatarRunner.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

Added handling for AudioSegmentEnd in the LiveAvatar audio forwarding loop to emit a playback-finished notification when audio segments complete, allowing pending RPCs that await audio playback to properly resolve.

Changes

Cohort / File(s) Summary
LiveAvatar Audio Forwarding
livekit/plugins/liveavatar/avatar.py
Imported AudioSegmentEnd and added conditional logic in _forward_audio to detect segment end markers, mark playback as finished, notify the audio buffer with current playback position, and reset playback state.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • longcw

Poem

🐰 A segment ends, the audio's done,
Notify the buffer—playback is spun!
No more hanging waits in the flow,
The finish event makes the RPC go! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: emitting playback_finished on AudioSegmentEnd to fix LiveAvatar playback hanging.
Linked Issues check ✅ Passed The code changes directly implement the proposed solution from issue #4668, handling AudioSegmentEnd by calling notify_playback_finished and resetting playback position.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue: adding AudioSegmentEnd import and handling in the _forward_audio loop to fix the playback hanging problem.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc8ca0d and cd63040.

📒 Files selected for processing (1)
  • livekit-plugins/livekit-plugins-liveavatar/livekit/plugins/liveavatar/avatar.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Format code with ruff
Run ruff linter and auto-fix issues
Run mypy type checker in strict mode
Maintain line length of 100 characters maximum
Ensure Python 3.9+ compatibility
Use Google-style docstrings

Files:

  • livekit-plugins/livekit-plugins-liveavatar/livekit/plugins/liveavatar/avatar.py
🧠 Learnings (1)
📚 Learning: 2026-01-30T12:53:12.738Z
Learnt from: milanperovic
Repo: livekit/agents PR: 4660
File: livekit-plugins/livekit-plugins-personaplex/livekit/plugins/personaplex/__init__.py:19-21
Timestamp: 2026-01-30T12:53:12.738Z
Learning: In plugin __init__.py files under the livekit-plugins or similar plugin directories, place internal imports (for example, from .log import logger) after the __all__ definition. These imports are used for plugin registration and are not part of the public API. This pattern is used across plugins (e.g., openai, deepgram, ultravox) and helps avoid E402 violations while keeping the public API surface clean.

Applied to files:

  • livekit-plugins/livekit-plugins-liveavatar/livekit/plugins/liveavatar/avatar.py
🧬 Code graph analysis (1)
livekit-plugins/livekit-plugins-liveavatar/livekit/plugins/liveavatar/avatar.py (2)
livekit-agents/livekit/agents/voice/avatar/_types.py (1)
  • AudioSegmentEnd (10-11)
livekit-agents/livekit/agents/voice/avatar/_queue_io.py (1)
  • QueueAudioOutput (17-70)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: unit-tests
  • GitHub Check: type-check (3.13)
  • GitHub Check: type-check (3.9)
🔇 Additional comments (2)
livekit-plugins/livekit-plugins-liveavatar/livekit/plugins/liveavatar/avatar.py (2)

25-25: Good: explicit import for AudioSegmentEnd handling.
Keeps the dependency clear and matches the new branch below.


222-229: LGTM: playback_finished emitted on segment end.
This closes the session.say() hang path and resets state cleanly.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@MSameerAbbas
Copy link
Contributor Author

MSameerAbbas commented Jan 30, 2026

@tinalenguyen @chenghao-mou pls review

Copy link
Member

@tinalenguyen tinalenguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thank you for the PR!!

@tinalenguyen tinalenguyen merged commit cdc0ed3 into livekit:main Jan 30, 2026
11 checks passed
zach-iee pushed a commit to sendbird/livekit-agents that referenced this pull request Feb 2, 2026
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.

Bug Report: LiveAvatar playback_finished not emitted

2 participants