From fa6e5ce4a74962f408be9c895944427ed1120b1a Mon Sep 17 00:00:00 2001 From: richtermb Date: Tue, 29 Jul 2025 10:43:18 -0700 Subject: [PATCH 1/5] Add on_transcription_error callback to DailyCallbacks and handle transcription errors in DailyTransportClient --- src/pipecat/transports/services/daily.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index ce1f671a6..ceb65ea8b 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_error: Called when transcription encounters an error. on_recording_started: Called when recording starts. on_recording_stopped: Called when recording stops. on_recording_error: Called when recording encounters an error. @@ -253,6 +254,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_error: Callable[[str], Awaitable[None]] on_recording_started: Callable[[Mapping[str, Any]], Awaitable[None]] on_recording_stopped: Callable[[str], Awaitable[None]] on_recording_error: Callable[[str, str], Awaitable[None]] @@ -1241,6 +1243,7 @@ class DailyTransportClient(EventHandler): message: Error message. """ logger.error(f"Transcription error: {message}") + self._call_event_callback(self._callbacks.on_transcription_error, message) def on_transcription_message(self, message): """Handle transcription message events. From d3d36a89e2db1ceae0625ccddce914777eff671b Mon Sep 17 00:00:00 2001 From: richtermb Date: Tue, 29 Jul 2025 10:48:50 -0700 Subject: [PATCH 2/5] Add _on_transcription_error method to DailyTransport for handling transcription error events --- src/pipecat/transports/services/daily.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index ceb65ea8b..9f312c1f7 100644 --- a/src/pipecat/transports/services/daily.py +++ b/src/pipecat/transports/services/daily.py @@ -1837,6 +1837,7 @@ class DailyTransport(BaseTransport): on_participant_left=self._on_participant_left, on_participant_updated=self._on_participant_updated, on_transcription_message=self._on_transcription_message, + on_transcription_error=self._on_transcription_error, on_recording_started=self._on_recording_started, on_recording_stopped=self._on_recording_stopped, on_recording_error=self._on_recording_error, @@ -2321,6 +2322,10 @@ class DailyTransport(BaseTransport): if self._input: await self._input.push_transcription_frame(frame) + async def _on_transcription_error(self, message): + """Handle transcription error events.""" + await self._call_event_handler("on_transcription_error", message) + async def _on_recording_started(self, status): """Handle recording started events.""" await self._call_event_handler("on_recording_started", status) From 444b1b5b02bb357635a3e91ee7e9e9dd043df662 Mon Sep 17 00:00:00 2001 From: richtermb Date: Tue, 29 Jul 2025 11:49:28 -0700 Subject: [PATCH 3/5] 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) From c1df19982c38c317e89c8e18e88d39510c2f62a7 Mon Sep 17 00:00:00 2001 From: richtermb Date: Tue, 29 Jul 2025 11:50:16 -0700 Subject: [PATCH 4/5] Add on_transcription_stopped callback to DailyTransport for handling transcription stop events --- src/pipecat/transports/services/daily.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index 78c2f636e..cd01c23a4 100644 --- a/src/pipecat/transports/services/daily.py +++ b/src/pipecat/transports/services/daily.py @@ -1840,6 +1840,7 @@ class DailyTransport(BaseTransport): on_participant_left=self._on_participant_left, on_participant_updated=self._on_participant_updated, on_transcription_message=self._on_transcription_message, + on_transcription_stopped=self._on_transcription_stopped, on_transcription_error=self._on_transcription_error, on_recording_started=self._on_recording_started, on_recording_stopped=self._on_recording_stopped, From 67107d02ed09994a382560fc525ad04ac6286eec Mon Sep 17 00:00:00 2001 From: richtermb Date: Tue, 29 Jul 2025 11:53:41 -0700 Subject: [PATCH 5/5] Refactor callback invocation for on_transcription_stopped in DailyTransportClient for improved readability --- src/pipecat/transports/services/daily.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index cd01c23a4..1ad443cb5 100644 --- a/src/pipecat/transports/services/daily.py +++ b/src/pipecat/transports/services/daily.py @@ -1237,7 +1237,9 @@ 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) + self._call_event_callback( + self._callbacks.on_transcription_stopped, stopped_by, stopped_by_error + ) def on_transcription_error(self, message): """Handle transcription error events.