Skip to content

Commit

Permalink
fix video_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkDaoust committed Dec 20, 2024
1 parent e9ecfaa commit 0ddb0b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions gemini-2/live_api_starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions gemini-2/websockets/live_api_starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 0ddb0b5

Please sign in to comment.