Add on_transcription_stopped callback to DailyCallbacks and implement handling in DailyTransport for transcription stop events

This commit is contained in:
richtermb
2025-07-29 11:49:28 -07:00
parent d3d36a89e2
commit 444b1b5b02
2 changed files with 9 additions and 0 deletions

View File

@@ -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

View File

@@ -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)