vishwask commited on
Commit
55221df
·
1 Parent(s): 4e88555

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -196,12 +196,13 @@ if prompt := st.chat_input("How can I help you today?"):
196
  st.session_state.audio = False
197
 
198
  with st.sidebar:
199
- choice = st.radio("References and TTS",["Reference" , 'TTS'])
200
-
201
- if choice == 'Reference':
202
- generate_pdf()
203
- st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
204
- st.image(st.session_state['reference'])
 
205
 
206
  # if choice == 'TTS':
207
  # generate_audio()
@@ -209,11 +210,14 @@ if prompt := st.chat_input("How can I help you today?"):
209
  # st.audio(st.session_state['audio'])
210
 
211
  if choice == 'TTS':
212
- sound_file = BytesIO()
213
- tts = gTTS(result['result'], lang='en', tld = 'co.in')
214
- tts.write_to_fp(sound_file)
215
- st.session_state['audio'] = sound_file
216
- st.audio(sound_file)
 
 
 
217
 
218
  st.session_state.messages.append({"role": "assistant", "content": full_response})
219
 
 
196
  st.session_state.audio = False
197
 
198
  with st.sidebar:
199
+ #choice = st.radio("References and TTS",["Reference" , 'TTS'])
200
+ choice = st.radio("References and TTS",['TTS'])
201
+
202
+ # if choice == 'Reference':
203
+ # generate_pdf()
204
+ # st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
205
+ # st.image(st.session_state['reference'])
206
 
207
  # if choice == 'TTS':
208
  # generate_audio()
 
210
  # st.audio(st.session_state['audio'])
211
 
212
  if choice == 'TTS':
213
+ with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
214
+ #sound_file = BytesIO()
215
+ tts = gTTS(result['result'], lang='en', tld = 'co.in')
216
+ tts.write_to_fp(sound_file)
217
+ sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
218
+ sound.export("/home/user/app/audio/audio.wav", format="wav")
219
+ st.session_state['audio'] = '/home/user/app/audio/audio.wav'
220
+ st.audio(st.session_state['audio'])
221
 
222
  st.session_state.messages.append({"role": "assistant", "content": full_response})
223