From a9b1298f3bd6f89274a9e7c8bf2ab0bccb03e14f Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Mon, 24 Mar 2025 10:25:31 -0400 Subject: [PATCH] Fix: RTVIObserver now outputs a single bot started and stopped speaking event per turn --- CHANGELOG.md | 3 +++ src/pipecat/processors/frameworks/rtvi.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c79c8f3b3..946d6bfa8 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 issue where the `RTVIObserver` would report two bot started and + stopped speaking events for each bot turn. + - Fixed an issue in `UltravoxSTTService` that caused improper audio processing and incorrect LLM frame output. diff --git a/src/pipecat/processors/frameworks/rtvi.py b/src/pipecat/processors/frameworks/rtvi.py index bb97c2098..f782e6ea8 100644 --- a/src/pipecat/processors/frameworks/rtvi.py +++ b/src/pipecat/processors/frameworks/rtvi.py @@ -440,7 +440,9 @@ class RTVIObserver(BaseObserver): if isinstance(frame, (UserStartedSpeakingFrame, UserStoppedSpeakingFrame)): await self._handle_interruptions(frame) - elif isinstance(frame, (BotStartedSpeakingFrame, BotStoppedSpeakingFrame)): + elif isinstance(frame, (BotStartedSpeakingFrame, BotStoppedSpeakingFrame)) and ( + direction == FrameDirection.UPSTREAM + ): await self._handle_bot_speaking(frame) elif isinstance(frame, (TranscriptionFrame, InterimTranscriptionFrame)): await self._handle_user_transcriptions(frame)