diff --git a/CHANGELOG.md b/CHANGELOG.md index e8c2809ff..74a9b739f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,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