From 5b49597854c600afa805972fb78a1a08c87bcbbd Mon Sep 17 00:00:00 2001 From: Moishe Lettvin Date: Fri, 12 Jan 2024 13:54:55 -0500 Subject: [PATCH] Pass entire transcription message on queue; don't respond to yourself in 06- --- src/dailyai/services/daily_transport_service.py | 4 +--- src/samples/theoretical-to-real/06-listen-and-respond.py | 6 +++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dailyai/services/daily_transport_service.py b/src/dailyai/services/daily_transport_service.py index 1f1fe483b..89cb66046 100644 --- a/src/dailyai/services/daily_transport_service.py +++ b/src/dailyai/services/daily_transport_service.py @@ -259,10 +259,8 @@ class DailyTransportService(EventHandler): pass def on_transcription_message(self, message): - print("got transcription", message) if self.loop: - asyncio.run_coroutine_threadsafe(self.transcription_queue.put(message["text"]), self.loop) - print("put transcription in queue", message) + asyncio.run_coroutine_threadsafe(self.transcription_queue.put(message), self.loop) def on_transcription_stopped(self, stopped_by, stopped_by_error): pass diff --git a/src/samples/theoretical-to-real/06-listen-and-respond.py b/src/samples/theoretical-to-real/06-listen-and-respond.py index 034e608f0..6cdac1491 100644 --- a/src/samples/theoretical-to-real/06-listen-and-respond.py +++ b/src/samples/theoretical-to-real/06-listen-and-respond.py @@ -33,7 +33,11 @@ async def main(room_url:str, token): sentence = "" async for message in transport.get_transcriptions(): - sentence += message + if message["session_id"] == transport.my_participant_id: + continue + + # todo: we could differentiate between transcriptions from different participants + sentence += message["text"] if sentence.endswith((".", "?", "!")): messages.append({"role": "user", "content": sentence}) sentence = ''