app.py add link, video now works during recoring
Browse files
app.py
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
import asyncio
|
2 |
import base64
|
3 |
import os
|
@@ -43,6 +46,8 @@ def encode_image(data: np.ndarray) -> dict:
|
|
43 |
if not isinstance(data, np.ndarray):
|
44 |
raise TypeError("encode_image expected a numpy.ndarray")
|
45 |
try:
|
|
|
|
|
46 |
with BytesIO() as output_bytes:
|
47 |
pil_image = Image.fromarray(data)
|
48 |
pil_image.save(output_bytes, "JPEG")
|
@@ -153,7 +158,6 @@ class GeminiHandler(AsyncAudioVideoStreamHandler):
|
|
153 |
finally:
|
154 |
update_gemini_status_sync()
|
155 |
|
156 |
-
|
157 |
async def generator(self):
|
158 |
if not self.session:
|
159 |
logger.warning("Gemini session is not initialized.")
|
|
|
1 |
+
# https://huggingface.co/spaces/freddyaboulton/gemini-audio-video-chat
|
2 |
+
# related demos: https://github.com/freddyaboulton/gradio-webrtc
|
3 |
+
|
4 |
import asyncio
|
5 |
import base64
|
6 |
import os
|
|
|
46 |
if not isinstance(data, np.ndarray):
|
47 |
raise TypeError("encode_image expected a numpy.ndarray")
|
48 |
try:
|
49 |
+
# Ensure the frame is float32
|
50 |
+
data = data.astype(np.float32)
|
51 |
with BytesIO() as output_bytes:
|
52 |
pil_image = Image.fromarray(data)
|
53 |
pil_image.save(output_bytes, "JPEG")
|
|
|
158 |
finally:
|
159 |
update_gemini_status_sync()
|
160 |
|
|
|
161 |
async def generator(self):
|
162 |
if not self.session:
|
163 |
logger.warning("Gemini session is not initialized.")
|