From 349fc526d72cf75b9e0f4032ce4780bafac36fed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Wed, 15 May 2024 15:23:24 -0700 Subject: [PATCH] transports(daily): avoid locking if no participant has joined yet --- CHANGELOG.md | 3 +++ src/pipecat/transports/services/daily.py | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97cdc8420..f96a80275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- Fixed an issue in `DailyTransport` that would not allow the processor to + shutdown if no participant ever joined the room. + - Fixed transport start and stop. In some situation processors would halt or not shutdown properly. diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index fc29fa81d..b280ee4d8 100644 --- a/src/pipecat/transports/services/daily.py +++ b/src/pipecat/transports/services/daily.py @@ -182,7 +182,14 @@ class DailyTransportClient(EventHandler): self._client.send_app_message(frame.message, frame.participant_id) def read_raw_audio_frames(self, frame_count: int) -> bytes: - return self._speaker.read_frames(frame_count) + if self._other_participant_has_joined: + return self._speaker.read_frames(frame_count) + else: + # If no one has ever joined the meeting `read_frames()` would block, + # instead we just wait a bit. daily-python should probably return + # silence instead. + time.sleep(0.01) + return b'' def write_raw_audio_frames(self, frames: bytes): self._mic.write_frames(frames)