vishwask commited on
Commit
29bb987
·
1 Parent(s): 18a034f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -172,14 +172,12 @@ if prompt := st.chat_input("How can I help you today?"):
172
  #st.session_state.reference = True
173
 
174
  st.session_state['reference'] = '/home/user/app/pdf2image/default_output.png'
175
- st.session_state['audio'] = ''
176
 
177
 
178
  def generate_audio():
179
- sound_file = BytesIO()
180
  tts = gTTS(result['result'], lang='en')
181
- tts.write_to_fp(sound_file)
182
- return sound_file
183
 
184
  for item in output:
185
  full_response += item
@@ -201,9 +199,9 @@ if prompt := st.chat_input("How can I help you today?"):
201
  st.image(st.session_state['reference'])
202
 
203
  if choice == 'TTS':
204
- x=generate_audio()
205
- st.session_state['audio'] = x
206
- st.image(st.session_state['audio'])
207
 
208
  st.session_state.messages.append({"role": "assistant", "content": full_response})
209
 
 
172
  #st.session_state.reference = True
173
 
174
  st.session_state['reference'] = '/home/user/app/pdf2image/default_output.png'
175
+ st.session_state['audio'] = '/home/user/app/audio/audio.mp3'
176
 
177
 
178
  def generate_audio():
 
179
  tts = gTTS(result['result'], lang='en')
180
+ tts.save('/home/user/app/audio/audio.mp3')
 
181
 
182
  for item in output:
183
  full_response += item
 
199
  st.image(st.session_state['reference'])
200
 
201
  if choice == 'TTS':
202
+ generate_audio()
203
+ st.session_state['audio'] = '/home/user/app/audio/audio.mp3'
204
+ st.audio(st.session_state['audio'])
205
 
206
  st.session_state.messages.append({"role": "assistant", "content": full_response})
207