Skip to content

Commit e399b9b

Browse files
authored
fix: pass queueSizeMs from RoomOutputOptions through to AudioSource (#1207)
Co-authored-by: cxyangs <27497414+cxyangs@users.noreply.github.com>
1 parent b407494 commit e399b9b

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@livekit/agents": patch
3+
---
4+
5+
fix: pass queueSizeMs from RoomOutputOptions through to AudioSource

agents/src/ipc/proc_pool.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-FileCopyrightText: 2026 LiveKit, Inc.
22
//
33
// SPDX-License-Identifier: Apache-2.0
4-
import { Throws } from '@livekit/throws-transformer/throws';
4+
import type { Throws } from '@livekit/throws-transformer/throws';
55
import { describe, expect, it, vi } from 'vitest';
66
import type { RunningJobInfo } from '../job.js';
77
import { type JobExecutor, JobStatus } from './job_executor.js';

agents/src/voice/room_io/_output.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,11 @@ export class ParticipantAudioOutput extends AudioOutput {
333333
super(options.sampleRate, undefined, { pause: true });
334334
this.room = room;
335335
this.options = options;
336-
this.audioSource = new AudioSource(options.sampleRate, options.numChannels);
336+
this.audioSource = new AudioSource(
337+
options.sampleRate,
338+
options.numChannels,
339+
options.queueSizeMs,
340+
);
337341
}
338342

339343
get subscribed(): boolean {

agents/src/voice/room_io/room_io.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ export interface RoomOutputOptions {
9595
/** The name of the audio track to publish. If not provided, default to "roomio_audio".
9696
*/
9797
audioPublishOptions: TrackPublishOptions;
98+
/** Maximum queue size in milliseconds for the audio output buffer.
99+
When TTS generates audio faster than real-time, a larger queue prevents
100+
early frames from being discarded by the ring buffer.
101+
Defaults to the AudioSource internal default (1000ms).
102+
*/
103+
queueSizeMs?: number;
98104
}
99105

100106
const DEFAULT_ROOM_INPUT_OPTIONS: RoomInputOptions = {
@@ -462,6 +468,7 @@ export class RoomIO {
462468
sampleRate: this.outputOptions.audioSampleRate,
463469
numChannels: this.outputOptions.audioNumChannels,
464470
trackPublishOptions: this.outputOptions.audioPublishOptions,
471+
queueSizeMs: this.outputOptions.queueSizeMs,
465472
});
466473
}
467474
if (this.outputOptions.transcriptionEnabled) {

0 commit comments

Comments
 (0)