From 8b641089f8e830013975a36ec9f4cf9d7bf1b85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Thu, 14 Aug 2025 14:43:17 -0700 Subject: [PATCH] AudioBufferProcessor: fix overlap when buffer size is set --- CHANGELOG.md | 3 +++ src/pipecat/processors/audio/audio_buffer_processor.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bdaeb794..9bc37e0fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed an `AudioBufferProcessor` issues that would cause audio overlap when + setting a max buffer size. + - Fixed an issue where `AsyncAITTSService` had very high latency in responding by adding `force=true` when sending the flush command. diff --git a/src/pipecat/processors/audio/audio_buffer_processor.py b/src/pipecat/processors/audio/audio_buffer_processor.py index b6432dd64..52c251bca 100644 --- a/src/pipecat/processors/audio/audio_buffer_processor.py +++ b/src/pipecat/processors/audio/audio_buffer_processor.py @@ -178,6 +178,7 @@ class AudioBufferProcessor(FrameProcessor): Calls audio handlers with any remaining buffered audio before stopping. """ await self._call_on_audio_data_handler() + self._reset_recording() self._recording = False async def process_frame(self, frame: Frame, direction: FrameDirection): @@ -230,6 +231,7 @@ class AudioBufferProcessor(FrameProcessor): if self._buffer_size > 0 and len(self._user_audio_buffer) > self._buffer_size: await self._call_on_audio_data_handler() + self._reset_recording() # Process turn recording with preprocessed data. if self._enable_turn_audio: @@ -288,8 +290,6 @@ class AudioBufferProcessor(FrameProcessor): self._num_channels, ) - self._reset_audio_buffers() - def _buffer_has_audio(self, buffer: bytearray) -> bool: """Check if a buffer contains audio data.""" return buffer is not None and len(buffer) > 0