From c4f9171fe106d1662b4d48efa23020d8f59a4366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Wed, 26 Mar 2025 14:37:36 -0700 Subject: [PATCH] frames: indicate if UserStartedSpeakingFrame/UserStoppedSpeakingFrame are emulated --- CHANGELOG.md | 12 ++++++++++-- src/pipecat/frames/frames.py | 4 ++-- src/pipecat/transports/base_input.py | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a93901bd1..69b1ba743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to **Pipecat** will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- It is now possible to tell whether `UserStartedSpeakingFrame` or + `UserStoppedSpeakingFrame` have been generated because of emulation frames. + ## [0.0.61] - 2025-03-26 ### Added @@ -21,9 +28,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - ElevenLabs TTS services now support a sample rate of 8000. -- Added support for `instructions` in `OpenAITTSService` +- Added support for `instructions` in `OpenAITTSService`. -- Added support for `base_url` in `OpenAIImageGenService` and `OpenAITTSService` +- Added support for `base_url` in `OpenAIImageGenService` and + `OpenAITTSService`. ### Fixed diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index 11cd17801..30d8622d9 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -562,14 +562,14 @@ class UserStartedSpeakingFrame(SystemFrame): """ - pass + emulated: bool = False @dataclass class UserStoppedSpeakingFrame(SystemFrame): """Emitted by the VAD to indicate that a user stopped speaking.""" - pass + emulated: bool = False @dataclass diff --git a/src/pipecat/transports/base_input.py b/src/pipecat/transports/base_input.py index 971dfe066..26f386576 100644 --- a/src/pipecat/transports/base_input.py +++ b/src/pipecat/transports/base_input.py @@ -117,10 +117,10 @@ class BaseInputTransport(FrameProcessor): await self._handle_bot_interruption(frame) elif isinstance(frame, EmulateUserStartedSpeakingFrame): logger.debug("Emulating user started speaking") - await self._handle_user_interruption(UserStartedSpeakingFrame()) + await self._handle_user_interruption(UserStartedSpeakingFrame(emulated=True)) elif isinstance(frame, EmulateUserStoppedSpeakingFrame): logger.debug("Emulating user stopped speaking") - await self._handle_user_interruption(UserStoppedSpeakingFrame()) + await self._handle_user_interruption(UserStoppedSpeakingFrame(emulated=True)) # All other system frames elif isinstance(frame, SystemFrame): await self.push_frame(frame, direction)