uasername commited on
Commit
5b1a089
·
verified ·
1 Parent(s): e2e574f

Update Gradio_UI.py

Browse files
Files changed (1) hide show
  1. Gradio_UI.py +4 -4
Gradio_UI.py CHANGED
@@ -187,8 +187,8 @@ def stream_to_gradio(
187
  elif isinstance(final_answer, AgentAudio):
188
  yield gr.ChatMessage(
189
  role="assistant",
190
- #content={"path": final_answer.to_string(), "mime_type": "audio/mpeg"},
191
- content={"data": final_answer.value, "mime_type": "audio/mpeg"},
192
  )
193
  else:
194
  yield gr.ChatMessage(role="assistant", content=f"**Final answer:** {str(final_answer)}")
@@ -313,7 +313,7 @@ class GradioUI:
313
  if isinstance(msg.content, dict):
314
  mime = msg.content.get("mime_type", "")
315
  if mime.startswith("audio"):
316
- return msg.content.get("data")
317
  return None
318
 
319
  with gr.Blocks(fill_height=True) as demo:
@@ -331,7 +331,7 @@ class GradioUI:
331
  )
332
 
333
  # NEW: Add a dedicated audio player component below the chatbot.
334
- audio_player = gr.Audio(label="Audio Pronunciation", type="bytes")
335
 
336
  if self.file_upload_folder is not None:
337
  upload_file = gr.File(label="Upload a file")
 
187
  elif isinstance(final_answer, AgentAudio):
188
  yield gr.ChatMessage(
189
  role="assistant",
190
+ content={"path": final_answer.to_string(), "mime_type": "audio/mpeg"},
191
+ #content={"data": final_answer.value, "mime_type": "audio/mpeg"},
192
  )
193
  else:
194
  yield gr.ChatMessage(role="assistant", content=f"**Final answer:** {str(final_answer)}")
 
313
  if isinstance(msg.content, dict):
314
  mime = msg.content.get("mime_type", "")
315
  if mime.startswith("audio"):
316
+ return msg.content.get("path")
317
  return None
318
 
319
  with gr.Blocks(fill_height=True) as demo:
 
331
  )
332
 
333
  # NEW: Add a dedicated audio player component below the chatbot.
334
+ audio_player = gr.Audio(label="Audio Pronunciation", type="filepath")
335
 
336
  if self.file_upload_folder is not None:
337
  upload_file = gr.File(label="Upload a file")