From ec58dbd791af9283e0e641f5504893ee17945da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Thu, 8 Aug 2024 21:44:43 -0700 Subject: [PATCH] transports(daily): added on_participant_updated event Fixes #353 --- CHANGELOG.md | 2 ++ src/pipecat/transports/services/daily.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ca5faa16..01b6937c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added new `on_participant_updated` event to `DailyTransport`. + - Added `DailyRESTHelper.delete_room_by_name()`. - Added LLM and TTS usage metrics. Those will be enabled by when diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index 0c3cb5ccb..24a7f01bc 100644 --- a/src/pipecat/transports/services/daily.py +++ b/src/pipecat/transports/services/daily.py @@ -123,6 +123,7 @@ class DailyCallbacks(BaseModel): on_first_participant_joined: Callable[[Mapping[str, Any]], Awaitable[None]] on_participant_joined: Callable[[Mapping[str, Any]], Awaitable[None]] on_participant_left: Callable[[Mapping[str, Any], str], Awaitable[None]] + on_participant_updated: Callable[[Mapping[str, Any]], Awaitable[None]] def completion_callback(future): @@ -485,6 +486,9 @@ class DailyTransportClient(EventHandler): self._call_async_callback(self._callbacks.on_participant_left, participant, reason) + def on_participant_updated(self, participant): + self._call_async_callback(self._callbacks.on_participant_updated, participant) + def on_transcription_message(self, message: Mapping[str, Any]): participant_id = "" if "participantId" in message: @@ -745,6 +749,7 @@ class DailyTransport(BaseTransport): on_first_participant_joined=self._on_first_participant_joined, on_participant_joined=self._on_participant_joined, on_participant_left=self._on_participant_left, + on_participant_updated=self._on_participant_updated, ) self._params = params @@ -768,6 +773,7 @@ class DailyTransport(BaseTransport): self._register_event_handler("on_first_participant_joined") self._register_event_handler("on_participant_joined") self._register_event_handler("on_participant_left") + self._register_event_handler("on_participant_updated") # # BaseTransport @@ -909,6 +915,9 @@ class DailyTransport(BaseTransport): async def _on_participant_left(self, participant, reason): await self._call_event_handler("on_participant_left", participant, reason) + async def _on_participant_updated(self, participant): + await self._call_event_handler("on_participant_updated", participant) + async def _on_first_participant_joined(self, participant): await self._call_event_handler("on_first_participant_joined", participant)