From 6c17594f1fee852b80ef4362e5ee3bccf64fb3e1 Mon Sep 17 00:00:00 2001 From: Chad Bailey Date: Fri, 19 Jan 2024 16:53:35 +0000 Subject: [PATCH] modernized 01a --- src/samples/theoretical-to-real/01a-greet-user.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/samples/theoretical-to-real/01a-greet-user.py b/src/samples/theoretical-to-real/01a-greet-user.py index dfd33fee3..9f1c6bcc4 100644 --- a/src/samples/theoretical-to-real/01a-greet-user.py +++ b/src/samples/theoretical-to-real/01a-greet-user.py @@ -1,3 +1,4 @@ +import argparse import asyncio import time from typing import AsyncGenerator @@ -38,10 +39,7 @@ async def main(room_url): print(f"participant joined: {participant['info']['userName']}") if participant["info"]["isLocal"]: return - audio_generator: AsyncGenerator[bytes, None] = tts.run_tts(f"Hello there, {participant['info']['userName']}!") - - async for audio in audio_generator: - transport.output_queue.put(QueueFrame(FrameType.AUDIO, audio)) + await tts.say(f"Hello there, {participant['info']['userName']}!", transport.send_queue) print("setting up call state handler") @transport.event_handler("on_call_state_updated") @@ -52,4 +50,10 @@ async def main(room_url): if __name__ == "__main__": - asyncio.run(main("https://chad-hq.daily.co/howdy")) + parser = argparse.ArgumentParser(description="Simple Daily Bot Sample") + parser.add_argument( + "-u", "--url", type=str, required=True, help="URL of the Daily room to join" + ) + + args, unknown = parser.parse_known_args() + asyncio.run(main(args.url))