From 0ddb0b573ee5bdc8089ac675156b1932d543c8a3 Mon Sep 17 00:00:00 2001 From: Mark Daoust Date: Thu, 19 Dec 2024 16:40:19 -0800 Subject: [PATCH] fix video_mode --- gemini-2/live_api_starter.py | 6 +++--- gemini-2/websockets/live_api_starter.py | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gemini-2/live_api_starter.py b/gemini-2/live_api_starter.py index 17af68492..14e929c4e 100755 --- a/gemini-2/live_api_starter.py +++ b/gemini-2/live_api_starter.py @@ -244,9 +244,9 @@ async def run(self): send_text_task = tg.create_task(self.send_text()) tg.create_task(self.send_realtime()) tg.create_task(self.listen_audio()) - if self.MODE == "camera": + if self.video_mode == "camera": tg.create_task(self.get_frames()) - elif self.MODE == "screen": + elif self.video_mode == "screen": tg.create_task(self.get_screen()) tg.create_task(self.receive_audio()) @@ -269,7 +269,7 @@ async def run(self): type=str, default=DEFAULT_MODE, help="pixels to stream from", - choices=["camera", "screen"], + choices=["camera", "screen", "none"], ) args = parser.parse_args() main = AudioLoop(video_mode=args.mode) diff --git a/gemini-2/websockets/live_api_starter.py b/gemini-2/websockets/live_api_starter.py index e679aae83..1b0e688c4 100755 --- a/gemini-2/websockets/live_api_starter.py +++ b/gemini-2/websockets/live_api_starter.py @@ -84,6 +84,7 @@ class AudioLoop: def __init__(self, video_mode=DEFAULT_MODE): + self.video_mode=video_mode self.audio_in_queue = None self.out_queue = None @@ -174,8 +175,9 @@ async def get_screen(self): break await asyncio.sleep(1.0) - - await self.out_queue.put(frame) + + msg = {"realtime_input": {"media_chunks": frame}} + await self.out_queue.put(msg) async def send_realtime(self): while True: @@ -268,9 +270,9 @@ async def run(self): tg.create_task(self.send_realtime()) tg.create_task(self.listen_audio()) - if MODE == "camera": + if self.video_mode == "camera": tg.create_task(self.get_frames()) - elif MODE == "screen": + elif self.video_mode == "screen": tg.create_task(self.get_screen()) tg.create_task(self.receive_audio()) tg.create_task(self.play_audio())