Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pure Python audio chat app with Multimodal Live API #1551

Merged
merged 25 commits into from
Jan 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
freddyaboulton committed Jan 6, 2025
commit b28a2871de60e3ebe1b88151b8c693135a2a599d
7 changes: 5 additions & 2 deletions gemini/gradio-voice/app.py
holtskinner marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import base64
import pathlib
from typing import AsyncGenerator
from typing import AsyncGenerator, Literal

from google import genai
from google.genai.types import LiveConnectConfig
@@ -22,7 +22,10 @@ class GeminiHandler(AsyncStreamHandler):
"""Handler for the Gemini API"""

def __init__(
self, expected_layout="mono", output_sample_rate=24000, output_frame_size=480
self,
expected_layout: Literal["mono"] = "mono",
output_sample_rate: int = 24000,
output_frame_size: int = 480,
) -> None:
super().__init__(
expected_layout,
24 changes: 18 additions & 6 deletions gemini/gradio-voice/header.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<div style='text-align: center'>
<h1>Gen AI SDK Voice Chat</h1>
<p>Speak with Gemini using real-time audio streaming</p>
<p>You will need to enable Vertex AI <a href="https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com">here</a></p>
<p>Also make sure you have enabled default credentials <a href="https://cloud.google.com/docs/authentication/provide-credentials-adc#how-to">here</a></p>
</div>
<div style="text-align: center">
<h1>Gen AI SDK Voice Chat</h1>
<p>Speak with Gemini using real-time audio streaming</p>
<p>
You will need to enable Vertex AI
<a
href="https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com"
>here</a
>
</p>
<p>
Also make sure you have enabled default credentials
<a
href="https://cloud.google.com/docs/authentication/provide-credentials-adc#how-to"
>here</a
>
</p>
</div>
6 changes: 3 additions & 3 deletions gemini/gradio-voice/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#api-form {
width: 80%;
margin: auto;
}
width: 80%;
margin: auto;
}