Ivan000 commited on
Commit
277adea
·
verified ·
1 Parent(s): eb85787

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -24,9 +24,10 @@ def generate_response(history, user_input, temperature, max_new_tokens):
24
 
25
  # Generate speech
26
  tts = gTTS(text=generated_text, lang='en')
27
- tts.save("response.mp3")
 
28
 
29
- return history, "response.mp3"
30
 
31
  # Function to clear chat history
32
  def clear_chat():
@@ -82,12 +83,14 @@ with gr.Blocks(css=custom_css) as demo:
82
  send_btn = gr.Button("Send")
83
  clear_btn = gr.Button("Clear Chat")
84
 
 
 
85
  with gr.Accordion("Advanced Settings", open=False, elem_id="settings"):
86
  temperature_slider = gr.Slider(0, 1, 0.7, step=0.1, label="Temperature")
87
  max_new_tokens_slider = gr.Slider(1, 1000, 100, step=1, label="Max New Tokens")
88
 
89
- send_btn.click(generate_response, [chatbot, txt, temperature_slider, max_new_tokens_slider], [chatbot, "audio"])
90
- txt.submit(generate_response, [chatbot, txt, temperature_slider, max_new_tokens_slider], [chatbot, "audio"])
91
  clear_btn.click(clear_chat, outputs=[chatbot, txt])
92
 
93
  # Launch the interface
 
24
 
25
  # Generate speech
26
  tts = gTTS(text=generated_text, lang='en')
27
+ audio_path = "response.mp3"
28
+ tts.save(audio_path)
29
 
30
+ return history, audio_path
31
 
32
  # Function to clear chat history
33
  def clear_chat():
 
83
  send_btn = gr.Button("Send")
84
  clear_btn = gr.Button("Clear Chat")
85
 
86
+ audio_output = gr.Audio(label="Generated Speech", type="filepath")
87
+
88
  with gr.Accordion("Advanced Settings", open=False, elem_id="settings"):
89
  temperature_slider = gr.Slider(0, 1, 0.7, step=0.1, label="Temperature")
90
  max_new_tokens_slider = gr.Slider(1, 1000, 100, step=1, label="Max New Tokens")
91
 
92
+ send_btn.click(generate_response, [chatbot, txt, temperature_slider, max_new_tokens_slider], [chatbot, audio_output])
93
+ txt.submit(generate_response, [chatbot, txt, temperature_slider, max_new_tokens_slider], [chatbot, audio_output])
94
  clear_btn.click(clear_chat, outputs=[chatbot, txt])
95
 
96
  # Launch the interface