From 5957ddb038afda644ec57bf0909d855db4fde846 Mon Sep 17 00:00:00 2001 From: Vaibhav159 Date: Thu, 23 Jan 2025 23:17:18 +0530 Subject: [PATCH] adding missing audio buffer fix --- CHANGELOG.md | 4 ++++ src/pipecat/processors/audio/audio_buffer_processor.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ff694fc1..a20a336c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed an issue where `OpenAIRealtimeBetaLLMService` function calling resulted in an error. +- Fixed an issue in `AudioBufferProcessor` where the last audio buffer was not + being processed, in cases where the `_user_audio_buffer` was smaller than the + buffer size. + ### Performance - Replaced audio resampling library `resampy` with `soxr`. Resampling a 2:21s diff --git a/src/pipecat/processors/audio/audio_buffer_processor.py b/src/pipecat/processors/audio/audio_buffer_processor.py index 34825ab20..0c0d14b67 100644 --- a/src/pipecat/processors/audio/audio_buffer_processor.py +++ b/src/pipecat/processors/audio/audio_buffer_processor.py @@ -9,6 +9,7 @@ from pipecat.frames.frames import ( Frame, InputAudioRawFrame, OutputAudioRawFrame, + EndFrame, ) from pipecat.processors.frame_processor import FrameDirection, FrameProcessor @@ -86,6 +87,9 @@ class AudioBufferProcessor(FrameProcessor): if self._buffer_size > 0 and len(self._user_audio_buffer) > self._buffer_size: await self._call_on_audio_data_handler() + if isinstance(frame, EndFrame): + await self._call_on_audio_data_handler() + await self.push_frame(frame, direction) async def _call_on_audio_data_handler(self):