fahad11182 commited on
Commit
211a7b2
1 Parent(s): 2a1f982

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -26,7 +26,7 @@ def generate_response(message, system_message, max_tokens, temperature, top_p):
26
  tts.save(audio_file)
27
  return response, audio_file
28
 
29
- st.title("Hugging Face Chatbot with Voice Response")
30
 
31
  message = st.text_input("Enter your message:")
32
  system_message = st.text_input("System message:", value="You are a friendly Chatbot.")
@@ -37,4 +37,12 @@ top_p = st.slider("Top-p (nucleus sampling)", 0.1, 1.0, 0.95, step=0.05)
37
  if st.button("Generate Response"):
38
  response, audio_file = generate_response(message, system_message, max_tokens, temperature, top_p)
39
  st.write(response)
40
- st.audio(audio_file)
 
 
 
 
 
 
 
 
 
26
  tts.save(audio_file)
27
  return response, audio_file
28
 
29
+ st.title("Hi (:")
30
 
31
  message = st.text_input("Enter your message:")
32
  system_message = st.text_input("System message:", value="You are a friendly Chatbot.")
 
37
  if st.button("Generate Response"):
38
  response, audio_file = generate_response(message, system_message, max_tokens, temperature, top_p)
39
  st.write(response)
40
+
41
+ # Add HTML to autoplay the audio
42
+ audio_html = f"""
43
+ <audio autoplay>
44
+ <source src="data:audio/mpeg;base64,{open(audio_file, "rb").read().encode("base64").decode()}" type="audio/mp3">
45
+ Your browser does not support the audio element.
46
+ </audio>
47
+ """
48
+ st.markdown(audio_html, unsafe_allow_html=True)