From 444b1b5b02bb357635a3e91ee7e9e9dd043df662 Mon Sep 17 00:00:00 2001 From: richtermb Date: Tue, 29 Jul 2025 11:49:28 -0700 Subject: [PATCH] Add on_transcription_stopped callback to DailyCallbacks and implement handling in DailyTransport for transcription stop events --- CHANGELOG.md | 2 ++ src/pipecat/transports/services/daily.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d488476de..0982d6b4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `set_log_level` to `DailyTransport`, allowing setting the logging level for Daily's internal logging system. +- Added `on_transcription_stopped` and `on_transcription_error` to Daily callbacks. + ### Changed - Play delayed messages from `ElevenLabsTTSService` if they still belong to the diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index 9f312c1f7..78c2f636e 100644 --- a/src/pipecat/transports/services/daily.py +++ b/src/pipecat/transports/services/daily.py @@ -226,6 +226,7 @@ class DailyCallbacks(BaseModel): on_participant_left: Called when a participant leaves. on_participant_updated: Called when participant info is updated. on_transcription_message: Called when receiving transcription. + on_transcription_stopped: Called when transcription is stopped. on_transcription_error: Called when transcription encounters an error. on_recording_started: Called when recording starts. on_recording_stopped: Called when recording stops. @@ -254,6 +255,7 @@ class DailyCallbacks(BaseModel): on_participant_left: Callable[[Mapping[str, Any], str], Awaitable[None]] on_participant_updated: Callable[[Mapping[str, Any]], Awaitable[None]] on_transcription_message: Callable[[Mapping[str, Any]], Awaitable[None]] + on_transcription_stopped: Callable[[str, bool], Awaitable[None]] on_transcription_error: Callable[[str], Awaitable[None]] on_recording_started: Callable[[Mapping[str, Any]], Awaitable[None]] on_recording_stopped: Callable[[str], Awaitable[None]] @@ -1235,6 +1237,7 @@ class DailyTransportClient(EventHandler): stopped_by_error: Whether stopped due to error. """ logger.debug("Transcription stopped") + self._call_event_callback(self._callbacks.on_transcription_stopped, stopped_by, stopped_by_error) def on_transcription_error(self, message): """Handle transcription error events. @@ -2322,6 +2325,10 @@ class DailyTransport(BaseTransport): if self._input: await self._input.push_transcription_frame(frame) + async def _on_transcription_stopped(self, stopped_by, stopped_by_error): + """Handle transcription stopped events.""" + await self._call_event_handler("on_transcription_stopped", stopped_by, stopped_by_error) + async def _on_transcription_error(self, message): """Handle transcription error events.""" await self._call_event_handler("on_transcription_error", message)