From d7c8f8df53d1e8d190f4ba4943bc0a09e315d84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 23 Sep 2025 15:41:47 -0700 Subject: [PATCH] update CHANGELOG with AudioBufferProcessor fixes --- CHANGELOG.md | 3 +++ .../audio/audio_buffer_processor.py | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad49ae5d7..f3169f278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -102,6 +102,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed an `AudioBufferProcessor` issues that was causing user audio to be + missing in stereo recordings causing bot and user overlaps. + - Fixed a `BaseOutputTransport` issue that could produce large saved `AudioBufferProcessor` files when using an audio mixer. diff --git a/src/pipecat/processors/audio/audio_buffer_processor.py b/src/pipecat/processors/audio/audio_buffer_processor.py index fefbafc9b..378393d9d 100644 --- a/src/pipecat/processors/audio/audio_buffer_processor.py +++ b/src/pipecat/processors/audio/audio_buffer_processor.py @@ -234,7 +234,7 @@ class AudioBufferProcessor(FrameProcessor): or len(self._bot_audio_buffer) >= self._buffer_size ): await self._call_on_audio_data_handler() - self._clear_primary_audio_buffers() + self._reset_primary_audio_buffers() # Process turn recording with preprocessed data. if self._enable_turn_audio: @@ -308,22 +308,25 @@ class AudioBufferProcessor(FrameProcessor): def _reset_recording(self): """Reset recording state and buffers.""" - self._reset_audio_buffers() + self._reset_all_audio_buffers() self._last_user_frame_at = time.time() self._last_bot_frame_at = time.time() - def _reset_audio_buffers(self): + def _reset_all_audio_buffers(self): """Reset all audio buffers to empty state.""" - self._user_audio_buffer = bytearray() - self._bot_audio_buffer = bytearray() - self._user_turn_audio_buffer = bytearray() - self._bot_turn_audio_buffer = bytearray() + self._reset_primary_audio_buffers() + self._reset_turn_audio_buffers() - def _clear_primary_audio_buffers(self): + def _reset_primary_audio_buffers(self): """Clear user and bot buffers while preserving turn buffers and timestamps.""" self._user_audio_buffer = bytearray() self._bot_audio_buffer = bytearray() + def _reset_turn_audio_buffers(self): + """Clear user and bot turn buffers while preserving primary buffers and timestamps.""" + self._user_turn_audio_buffer = bytearray() + self._bot_turn_audio_buffer = bytearray() + def _align_track_buffers(self): """Pad the shorter track with silence so both tracks stay in sync.""" user_len = len(self._user_audio_buffer)