nikshep01 commited on
Commit
cdc0a26
·
verified ·
1 Parent(s): 8e6149e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -69,12 +69,20 @@ import gradio as gr
69
 
70
  def fake(message, history):
71
  if message.strip():
72
- return gr.Audio("https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav")
 
73
  else:
74
- return "Please provide the name of an artist"
75
 
76
- gr.ChatInterface(
77
- fn=fake,
78
- textbox=gr.Textbox(placeholder="Which artist's music do you want to listen to?", scale=7),
79
- chatbot=gr.Chatbot(placeholder="Play music by any artist!"),
80
- ).launch()
 
 
 
 
 
 
 
 
69
 
70
  def fake(message, history):
71
  if message.strip():
72
+ # Instead of returning audio directly, return a message
73
+ return "Playing sample audio...", gr.Audio("https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav")
74
  else:
75
+ return "Please provide the name of an artist", None
76
 
77
+ with gr.Blocks() as demo:
78
+ chatbot = gr.Chatbot(placeholder="Play music by any artist!")
79
+ textbox = gr.Textbox(placeholder="Which artist's music do you want to listen to?", scale=7)
80
+ audio_player = gr.Audio()
81
+
82
+ def chat_interface(message, history):
83
+ response, audio = fake(message, history)
84
+ return history + [(message, response)], audio
85
+
86
+ textbox.submit(chat_interface, [textbox, chatbot], [chatbot, audio_player])
87
+
88
+ demo.launch()