From 65afee28082a3b64d9a24290ca0111d500aae350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 28 May 2024 16:19:15 -0700 Subject: [PATCH 1/3] transport(daily): add start_recording, stop_recording and stop_dialout --- CHANGELOG.md | 5 +++++ src/pipecat/transports/services/daily.py | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e083a678..9c1727b56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Added Daily transport `start_recording()`, `stop_recording` and + `stop_dialout`. + ### Changed - Added `PipelineParams`. This replaces the `allow_interruptions` argument in diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index 7832a1621..6ab2e55ae 100644 --- a/src/pipecat/transports/services/daily.py +++ b/src/pipecat/transports/services/daily.py @@ -345,6 +345,15 @@ class DailyTransportClient(EventHandler): def start_dialout(self, settings): self._client.start_dialout(settings) + def stop_dialout(self, participant_id): + self._client.stop_dialout(participant_id) + + def start_recording(self, streaming_settings, stream_id, force_new): + self._client.start_recording(streaming_settings, stream_id, force_new) + + def stop_recording(self, stream_id): + self._client.stop_recording(stream_id) + def capture_participant_transcription(self, participant_id: str, callback: Callable): if not self._params.transcription_enabled: return @@ -695,9 +704,18 @@ class DailyTransport(BaseTransport): if self._output: await self._output.process_frame(frame, FrameDirection.DOWNSTREAM) - def start_dialout(self, settings): + def start_dialout(self, settings=None): self._client.start_dialout(settings) + def stop_dialout(self, participant_id): + self._client.stop_dialout(participant_id) + + def start_recording(self, streaming_settings=None, stream_id=None, force_new=None): + self._client.start_recording(streaming_settings, stream_id, force_new) + + def stop_recording(self, stream_id=None): + self._client.stop_recording(stream_id) + def capture_participant_transcription(self, participant_id: str): self._client.capture_participant_transcription( participant_id, From 4cd4787e4dd8685c136768cf62959048ce6d6125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 28 May 2024 17:19:38 -0700 Subject: [PATCH 2/3] transports(daily): added on_call_state_updated --- CHANGELOG.md | 2 ++ src/pipecat/transports/services/daily.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c1727b56..fcaae4cb3 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 Daily transport `on_call_state_updated` event. + - Added Daily transport `start_recording()`, `stop_recording` and `stop_dialout`. diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index 6ab2e55ae..6d5006e9d 100644 --- a/src/pipecat/transports/services/daily.py +++ b/src/pipecat/transports/services/daily.py @@ -114,6 +114,7 @@ class DailyCallbacks(BaseModel): on_left: Callable[[], None] on_error: Callable[[str], None] on_app_message: Callable[[Any, str], None] + on_call_state_updated: Callable[[str], None] on_dialin_ready: Callable[[str], None] on_dialout_connected: Callable[[Any], None] on_dialout_stopped: Callable[[Any], None] @@ -390,6 +391,9 @@ class DailyTransportClient(EventHandler): def on_app_message(self, message: Any, sender: str): self._callbacks.on_app_message(message, sender) + def on_call_state_updated(self, state: str): + self._callbacks.on_call_state_updated(state) + def on_dialin_ready(self, sip_endpoint: str): self._callbacks.on_dialin_ready(sip_endpoint) @@ -644,6 +648,7 @@ class DailyTransport(BaseTransport): on_left=self._on_left, on_error=self._on_error, on_app_message=self._on_app_message, + on_call_state_updated=self._on_call_state_updated, on_dialin_ready=self._on_dialin_ready, on_dialout_connected=self._on_dialout_connected, on_dialout_stopped=self._on_dialout_stopped, @@ -666,6 +671,7 @@ class DailyTransport(BaseTransport): # these handlers. self._register_event_handler("on_joined") self._register_event_handler("on_left") + self._register_event_handler("on_call_state_updated") self._register_event_handler("on_dialout_connected") self._register_event_handler("on_dialout_stopped") self._register_event_handler("on_dialout_error") @@ -747,6 +753,9 @@ class DailyTransport(BaseTransport): if self._input: self._input.push_app_message(message, sender) + def _on_call_state_updated(self, state: str): + self.on_call_state_updated(state) + async def _handle_dialin_ready(self, sip_endpoint: str): async with aiohttp.ClientSession() as session: headers = { @@ -819,6 +828,9 @@ class DailyTransport(BaseTransport): def on_left(self): pass + def on_call_state_updated(self, state): + pass + def on_dialout_connected(self, data): pass From 08a15e5cdd4ff0ca8bc92b26fe79e00ac52dc48e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Tue, 28 May 2024 17:22:12 -0700 Subject: [PATCH 3/3] transports(daily): expose on_app_message --- CHANGELOG.md | 2 ++ src/pipecat/transports/services/daily.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcaae4cb3..b19c64876 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 +- Exposed Daily transport `on_app_message` event. + - Added Daily transport `on_call_state_updated` event. - Added Daily transport `start_recording()`, `stop_recording` and diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index 6d5006e9d..5491882f2 100644 --- a/src/pipecat/transports/services/daily.py +++ b/src/pipecat/transports/services/daily.py @@ -671,6 +671,7 @@ class DailyTransport(BaseTransport): # these handlers. self._register_event_handler("on_joined") self._register_event_handler("on_left") + self._register_event_handler("on_app_message") self._register_event_handler("on_call_state_updated") self._register_event_handler("on_dialout_connected") self._register_event_handler("on_dialout_stopped") @@ -752,6 +753,7 @@ class DailyTransport(BaseTransport): def _on_app_message(self, message: Any, sender: str): if self._input: self._input.push_app_message(message, sender) + self.on_app_message(message, sender) def _on_call_state_updated(self, state: str): self.on_call_state_updated(state) @@ -828,6 +830,9 @@ class DailyTransport(BaseTransport): def on_left(self): pass + def on_app_message(self, message, sender): + pass + def on_call_state_updated(self, state): pass