From fd2fa23e9cd410367b4bbbf6e61364565ccc7fae Mon Sep 17 00:00:00 2001 From: Moishe Lettvin Date: Mon, 11 Mar 2024 13:00:29 -0400 Subject: [PATCH] Fix example 2 --- src/examples/foundational/02-llm-say-one-thing.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/examples/foundational/02-llm-say-one-thing.py b/src/examples/foundational/02-llm-say-one-thing.py index 55a6863e8..fc596407b 100644 --- a/src/examples/foundational/02-llm-say-one-thing.py +++ b/src/examples/foundational/02-llm-say-one-thing.py @@ -42,15 +42,21 @@ async def main(room_url): } ] - @transport.event_handler("on_first_other_participant_joined") - async def on_first_other_participant_joined(transport): + other_joined_event = asyncio.Event() + async def speak_from_llm(): + await other_joined_event.wait() await tts.run_to_queue( transport.send_queue, llm.run([LLMMessagesQueueFrame(messages)]), + add_end_of_stream=True ) await transport.stop_when_done() - await transport.run() + @transport.event_handler("on_first_other_participant_joined") + async def on_first_other_participant_joined(transport): + other_joined_event.set() + + await asyncio.gather(transport.run(), speak_from_llm()) if __name__ == "__main__":