palbha commited on
Commit
1b68154
·
verified ·
1 Parent(s): b192aaf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
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
- chat = client.chats.create(model="gemini-2.0-flash") if not history else history[-1]
 
 
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 not audio: # This checks for both None and empty input
67
- return None, history, None
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