SaileshSivan commited on
Commit
cf84de0
·
1 Parent(s): aeddbec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -13
app.py CHANGED
@@ -69,8 +69,6 @@ with st.form(key='my_form',clear_on_submit=True):
69
  )
70
 
71
  input_question = st.text_input("Type here.", key="input")
72
- response_text, response_audio = get_chatmodel_response(input_text)
73
-
74
  submit = st.form_submit_button("Submit")
75
 
76
  # If the "Submit" button is clicked
@@ -83,21 +81,14 @@ if submit:
83
  st.caption(input_question)
84
 
85
  st.header("Sisi", divider=True)
86
- response = get_chatmodel_response(input_question)
87
 
88
  # Generate speech using OpenAI API
89
- response_audio = openai.audio.speech.create(
90
- model="tts-1",
91
- voice="alloy",
92
- input=response
93
- )
94
- # Display audio on the webpage
95
- st.audio(response_audio, format='audio/mp3')
96
 
97
  # Add a download button for the audio
98
- # Add a download button for the audio
99
- audio_data = base64.b64decode(response_audio.split(',')[1])
100
- st.markdown(f"### [Download Audio](data:audio/mp3;base64,{base64.b64encode(audio_data).decode()})", unsafe_allow_html=True)
101
 
102
  if response is not None:
103
 
 
69
  )
70
 
71
  input_question = st.text_input("Type here.", key="input")
 
 
72
  submit = st.form_submit_button("Submit")
73
 
74
  # If the "Submit" button is clicked
 
81
  st.caption(input_question)
82
 
83
  st.header("Sisi", divider=True)
84
+ response_text, response_audio = get_chatmodel_response(input_question)
85
 
86
  # Generate speech using OpenAI API
87
+ response_audio_data = base64.b64decode(response_audio.split(',')[1])
88
+ st.audio(response_audio_data, format='audio/mp3')
 
 
 
 
 
89
 
90
  # Add a download button for the audio
91
+ st.markdown(f"### [Download Audio](data:audio/mp3;base64,{base64.b64encode(response_audio_data).decode()})", unsafe_allow_html=True)
 
 
92
 
93
  if response is not None:
94