From 38d3e7932b349aa8d90f09b44eac6b1f883fab49 Mon Sep 17 00:00:00 2001 From: lukasIO Date: Wed, 11 Feb 2026 16:51:19 +0100 Subject: [PATCH 1/2] Ensure resampling is skipped for empty audio frames --- agents/src/stt/stt.ts | 5 +++++ agents/src/utils.ts | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/agents/src/stt/stt.ts b/agents/src/stt/stt.ts index 50f33bc71..837aae5b4 100644 --- a/agents/src/stt/stt.ts +++ b/agents/src/stt/stt.ts @@ -351,6 +351,11 @@ export abstract class SpeechStream implements AsyncIterableIterator } } + if (frame.samplesPerChannel === 0) { + this.input.put(frame); + return; + } + if (this.resampler) { const frames = this.resampler.push(frame); for (const frame of frames) { diff --git a/agents/src/utils.ts b/agents/src/utils.ts index 75033ff9a..fdd3c69ed 100644 --- a/agents/src/utils.ts +++ b/agents/src/utils.ts @@ -651,14 +651,22 @@ export function resampleStream({ let resampler: AudioResampler | null = null; const transformStream = new TransformStream({ transform(chunk: AudioFrame, controller: TransformStreamDefaultController) { + if (chunk.samplesPerChannel === 0) { + controller.enqueue(chunk); + return; + } if (!resampler) { resampler = new AudioResampler(chunk.sampleRate, outputRate); } for (const frame of resampler.push(chunk)) { controller.enqueue(frame); } - for (const frame of resampler.flush()) { - controller.enqueue(frame); + }, + flush(controller) { + if (resampler) { + for (const frame of resampler.flush()) { + controller.enqueue(frame); + } } }, }); From 03114de0fd8ca7d2fc82b3de22057ada8b40c22e Mon Sep 17 00:00:00 2001 From: Brian Yin Date: Wed, 11 Feb 2026 15:16:34 -0800 Subject: [PATCH 2/2] Create fair-needles-obey.md --- .changeset/fair-needles-obey.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fair-needles-obey.md diff --git a/.changeset/fair-needles-obey.md b/.changeset/fair-needles-obey.md new file mode 100644 index 000000000..6e8854b58 --- /dev/null +++ b/.changeset/fair-needles-obey.md @@ -0,0 +1,5 @@ +--- +"@livekit/agents": patch +--- + +Ensure resampling is skipped for empty audio frames