Spaces:
Running
Running
Commit
·
eae3f78
1
Parent(s):
d264a00
Add code
Browse files
app.py
CHANGED
@@ -20,15 +20,6 @@ class GeminiConfig:
|
|
20 |
self.model = "models/gemini-2.0-flash-exp"
|
21 |
self.ws_url = f"wss://{self.host}/ws/google.ai.generativelanguage.v1alpha.GenerativeService.BidiGenerateContent?key={self.api_key}"
|
22 |
|
23 |
-
def _get_api_key(self):
|
24 |
-
api_key = os.getenv("GOOGLE_API_KEY")
|
25 |
-
if not api_key:
|
26 |
-
raise ValueError(
|
27 |
-
"GOOGLE_API_KEY not found in environment variables. Please set it in your .env file."
|
28 |
-
)
|
29 |
-
return api_key
|
30 |
-
|
31 |
-
|
32 |
class AudioProcessor:
|
33 |
@staticmethod
|
34 |
def encode_audio(data, sample_rate):
|
@@ -208,14 +199,14 @@ class GeminiVoiceChat:
|
|
208 |
<div style='text-align: center'>
|
209 |
<h1>Gemini 2.0 Voice Chat</h1>
|
210 |
<p>Speak with Gemini using real-time audio streaming</p>
|
|
|
211 |
</div>
|
212 |
""")
|
213 |
|
214 |
with gr.Row(visible=True) as api_key_row:
|
215 |
api_key = gr.Textbox(
|
216 |
-
label="
|
217 |
-
placeholder="Enter your
|
218 |
-
value=os.getenv("GOOGLE_API_KEY"),
|
219 |
type="password",
|
220 |
)
|
221 |
with gr.Row(visible=False) as row:
|
|
|
20 |
self.model = "models/gemini-2.0-flash-exp"
|
21 |
self.ws_url = f"wss://{self.host}/ws/google.ai.generativelanguage.v1alpha.GenerativeService.BidiGenerateContent?key={self.api_key}"
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
class AudioProcessor:
|
24 |
@staticmethod
|
25 |
def encode_audio(data, sample_rate):
|
|
|
199 |
<div style='text-align: center'>
|
200 |
<h1>Gemini 2.0 Voice Chat</h1>
|
201 |
<p>Speak with Gemini using real-time audio streaming</p>
|
202 |
+
<p>Get a Gemini API key from <a href="https://ai.google.dev/gemini-api/docs/api-key">Google</a></p>
|
203 |
</div>
|
204 |
""")
|
205 |
|
206 |
with gr.Row(visible=True) as api_key_row:
|
207 |
api_key = gr.Textbox(
|
208 |
+
label="Gemini API Key",
|
209 |
+
placeholder="Enter your Gemini API Key",
|
|
|
210 |
type="password",
|
211 |
)
|
212 |
with gr.Row(visible=False) as row:
|