fix: pass queueSizeMs from RoomOutputOptions through to AudioSource#1207
Merged
toubatbrian merged 3 commits intolivekit:mainfrom Apr 7, 2026
Merged
Conversation
When TTS generates audio faster than real-time (2-10x burst), the AudioSource ring buffer overflows and discards the earliest frames, causing the beginning of agent speech to be truncated. AudioOutputOptions already declares `queueSizeMs` but ParticipantAudioOutput never forwards it to the AudioSource constructor. RoomOutputOptions also lacks the field entirely, making it impossible for callers to configure. This patch: - Adds `queueSizeMs?: number` to `RoomOutputOptions` - Forwards `options.queueSizeMs` to `AudioSource` in `ParticipantAudioOutput` - Passes `queueSizeMs` through in `RoomIO.start()`
🦋 Changeset detectedLatest commit: 4fb416f The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
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 |
Contributor
|
@cxyangs Could you fix the linting error? |
- Prettier: format AudioSource constructor call in _output.ts - ESLint: use type-only import for Throws in proc_pool.test.ts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2987856 to
4fb416f
Compare
toubatbrian
approved these changes
Apr 7, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AudioOutputOptionsalready declaresqueueSizeMs?: number, butParticipantAudioOutputnever forwards it toAudioSource, so the parameter is silently ignored.RoomOutputOptionslacksqueueSizeMsentirely, making it impossible for callers to configure the audio output buffer size.Root Cause
When TTS generates audio significantly faster than real-time (2–10× burst), the
AudioSourcering buffer (defaultqueueSizeMs = 1000) overflows. The oldest frames — which are the beginning of the agent's speech — are discarded, resulting in audible truncation of roughly 1 second at the start of each reply.Fix
_output.ts: Forwardoptions.queueSizeMsto theAudioSourceconstructor (3rd argument).room_io.ts: AddqueueSizeMs?: numbertoRoomOutputOptionsand pass it through when creatingParticipantAudioOutput.Backward Compatibility
Fully backward compatible. When
queueSizeMsis not specified (undefined),AudioSourceuses its existing default of 1000ms — behavior is unchanged for existing users.Test Plan
tsc --noEmit)queueSizeMs: 5000inRoomOutputOptionsand verify speech truncation is resolvedqueueSizeMsproduces the same behavior as before