syedmudassir16 commited on
Commit
7fb43f8
·
verified ·
1 Parent(s): 4cdf668

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -66,6 +66,7 @@ def format_prompt(message, history):
66
 
67
  Note: if user asks something like i need a coffee then do not classify the mood directly and ask more follow-up questions as asked in examples.
68
 
 
69
  """
70
  prompt = f"{fixed_prompt}\n"
71
  for user_prompt, bot_response in history:
@@ -85,7 +86,7 @@ def process_input(input_text, history):
85
  return history, history, "", None
86
  response = generate(input_text, history)
87
  history.append((input_text, response))
88
- return history, history, "", None
89
 
90
  async def generate_audio(history):
91
  if history and len(history) > 0:
@@ -103,15 +104,15 @@ async def init_chat():
103
  with gr.Blocks() as demo:
104
  gr.Markdown("# Mood-Based Music Recommender with Continuous Voice Chat")
105
 
106
- chatbot = gr.Chatbot(height=400)
107
- msg = gr.Textbox(placeholder="Type your message here or use the microphone to speak...", label="Your message")
108
  audio_output = gr.Audio(label="AI Response", autoplay=True)
109
 
110
  state = gr.State([])
111
 
112
  with gr.Row():
113
  submit = gr.Button("Send")
114
- voice_input = gr.Audio(sources="microphone", type="filepath", label="Voice Input")
115
 
116
  # Initialize chat with greeting
117
  demo.load(init_chat, outputs=[state, chatbot, audio_output])
 
66
 
67
  Note: if user asks something like i need a coffee then do not classify the mood directly and ask more follow-up questions as asked in examples.
68
 
69
+
70
  """
71
  prompt = f"{fixed_prompt}\n"
72
  for user_prompt, bot_response in history:
 
86
  return history, history, "", None
87
  response = generate(input_text, history)
88
  history.append((input_text, response))
89
+ return history, history, "", None # Return history twice: once for state, once for chatbot, and reset voice input
90
 
91
  async def generate_audio(history):
92
  if history and len(history) > 0:
 
104
  with gr.Blocks() as demo:
105
  gr.Markdown("# Mood-Based Music Recommender with Continuous Voice Chat")
106
 
107
+ chatbot = gr.Chatbot()
108
+ msg = gr.Textbox(placeholder="Type your message here or use the microphone to speak...")
109
  audio_output = gr.Audio(label="AI Response", autoplay=True)
110
 
111
  state = gr.State([])
112
 
113
  with gr.Row():
114
  submit = gr.Button("Send")
115
+ voice_input = gr.Audio(source="microphone", type="filepath", label="Voice Input")
116
 
117
  # Initialize chat with greeting
118
  demo.load(init_chat, outputs=[state, chatbot, audio_output])