Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -44,7 +44,9 @@ def chat_with_gemini(user_input, history):
|
|
44 |
history = []
|
45 |
global chat
|
46 |
# Initialize or continue conversation
|
47 |
-
|
|
|
|
|
48 |
|
49 |
print("User input:", user_input)
|
50 |
|
@@ -63,9 +65,9 @@ def chat_with_gemini(user_input, history):
|
|
63 |
|
64 |
def process_audio(audio, history):
|
65 |
"""Process audio input, convert to text, and get response."""
|
66 |
-
if
|
67 |
-
return
|
68 |
-
|
69 |
# Convert audio to text
|
70 |
user_input = transcribe_audio(audio)
|
71 |
|
|
|
44 |
history = []
|
45 |
global chat
|
46 |
# Initialize or continue conversation
|
47 |
+
if chat is None:
|
48 |
+
chat = client.chats.create(model="gemini-2.0-flash") # Initialize chat once
|
49 |
+
|
50 |
|
51 |
print("User input:", user_input)
|
52 |
|
|
|
65 |
|
66 |
def process_audio(audio, history):
|
67 |
"""Process audio input, convert to text, and get response."""
|
68 |
+
if audio is None:
|
69 |
+
return "No audio detected", history, None # Don't reset history
|
70 |
+
|
71 |
# Convert audio to text
|
72 |
user_input = transcribe_audio(audio)
|
73 |
|