Skip to content

Commit

Permalink
remove extra encoding/decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
holtskinner committed Jan 13, 2025
1 parent 58e47da commit a5857ff
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions gemini/multimodal-live-api/gradio-voice/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio
import base64
import pathlib
from typing import AsyncGenerator, Literal

Expand All @@ -19,11 +18,6 @@
current_dir = pathlib.Path(__file__).parent


def encode_audio(data: np.ndarray) -> str:
"""Encode Audio data to send to the server"""
return base64.b64encode(data.tobytes()).decode("UTF-8")


class GeminiHandler(AsyncStreamHandler):
"""Handler for the Gemini API"""

Expand Down Expand Up @@ -92,7 +86,7 @@ async def receive(self, frame: tuple[int, np.ndarray]) -> None:
"""Receive audio from the user and put it in the input stream."""
_, array = frame
array = array.squeeze()
audio_message = encode_audio(array)
audio_message = array.tobytes()
self.input_queue.put_nowait(audio_message)

async def generator(self) -> None:
Expand Down

0 comments on commit a5857ff

Please sign in to comment.