ariankhalfani commited on
Commit
3cff197
1 Parent(s): 8d57442

Update chatbot.py

Browse files
Files changed (1) hide show
  1. chatbot.py +7 -2
chatbot.py CHANGED
@@ -180,10 +180,15 @@ def cleanup_response(response):
180
  response = response[answer_start + len("Answer:"):].strip()
181
  return response
182
 
183
- # Gradio interface for the chatbot
184
  def chatbot(audio, input_type, text):
185
  if input_type == "Voice":
186
- transcription = query_whisper(audio.name)
 
 
 
 
 
 
187
  if "error" in transcription:
188
  return "Error transcribing audio: " + transcription["error"], None
189
  query = transcription['text']
 
180
  response = response[answer_start + len("Answer:"):].strip()
181
  return response
182
 
 
183
  def chatbot(audio, input_type, text):
184
  if input_type == "Voice":
185
+ # Check if audio is a string (file path) or a file object
186
+ if isinstance(audio, str):
187
+ audio_path = audio
188
+ else:
189
+ audio_path = audio.name
190
+
191
+ transcription = query_whisper(audio_path)
192
  if "error" in transcription:
193
  return "Error transcribing audio: " + transcription["error"], None
194
  query = transcription['text']