Ath commited on
Commit
97d1d38
·
verified ·
1 Parent(s): 23ea754

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -36,14 +36,14 @@ def chat_and_tts_text(user_input, history):
36
  # Update the chat history with text input and response
37
  history.append((user_input, response_text))
38
 
39
- return history, response_text
40
 
41
  def convert_audio_to_text(audio_file):
42
  # This is a placeholder function. Replace with actual implementation.
43
  # For now, we assume the function just returns a dummy text.
44
  return "Sample text from audio"
45
 
46
- def chat_and_tts_audio(audio_file):
47
  # Convert uploaded audio file to text
48
  user_input = convert_audio_to_text(audio_file)
49
 
@@ -75,7 +75,10 @@ def chat_and_tts_audio(audio_file):
75
  else:
76
  audio_path = None
77
 
78
- return response_text, audio_path
 
 
 
79
 
80
  # Create the Gradio UI
81
  with gr.Blocks() as demo:
@@ -98,6 +101,6 @@ with gr.Blocks() as demo:
98
  state = gr.State([])
99
 
100
  submit_btn_text.click(chat_and_tts_text, inputs=[user_input_text, state], outputs=[chatbot, state])
101
- submit_btn_audio.click(chat_and_tts_audio, inputs=[user_input_audio], outputs=[chatbot, audio_output])
102
 
103
  demo.launch()
 
36
  # Update the chat history with text input and response
37
  history.append((user_input, response_text))
38
 
39
+ return history, history
40
 
41
  def convert_audio_to_text(audio_file):
42
  # This is a placeholder function. Replace with actual implementation.
43
  # For now, we assume the function just returns a dummy text.
44
  return "Sample text from audio"
45
 
46
+ def chat_and_tts_audio(audio_file, history):
47
  # Convert uploaded audio file to text
48
  user_input = convert_audio_to_text(audio_file)
49
 
 
75
  else:
76
  audio_path = None
77
 
78
+ # Update the chat history with audio input and response
79
+ history.append((user_input, response_text))
80
+
81
+ return history, history, audio_path
82
 
83
  # Create the Gradio UI
84
  with gr.Blocks() as demo:
 
101
  state = gr.State([])
102
 
103
  submit_btn_text.click(chat_and_tts_text, inputs=[user_input_text, state], outputs=[chatbot, state])
104
+ submit_btn_audio.click(chat_and_tts_audio, inputs=[user_input_audio, state], outputs=[chatbot, state, audio_output])
105
 
106
  demo.launch()