vishwask commited on
Commit
37155db
1 Parent(s): 4c5bc27

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -17
app.py CHANGED
@@ -197,32 +197,23 @@ if prompt := st.chat_input("How can I help you today?"):
197
  st.session_state.audio = False
198
 
199
 
200
-
201
- #choice = st.radio("References and TTS",["Reference" , 'TTS'])
202
- on_ref = st.toggle('Reference', key='onref')
203
- st.session_state.onref = False
204
-
205
- if on_ref:
206
- st.session_state.onref = True
207
- with st.sidebar:
208
  generate_pdf()
209
  st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
210
- st.image(st.session_state['reference'])
211
-
212
- on_TTS = st.toggle('TTS', key='ontts')
213
- st.session_state.ontts = False
214
 
215
- if on_TTS:
216
- st.session_state.ontts = True
217
- with st.sidebar:
218
  with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
219
  tts = gTTS(result['result'], lang='en', tld = 'co.in')
220
  tts.write_to_fp(sound_file)
221
  sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
222
  sound.export("/home/user/app/audio/audio.wav", format="wav")
223
  st.session_state['audio'] = '/home/user/app/audio/audio.wav'
224
- st.audio(st.session_state['audio'])
225
-
226
  st.session_state.messages.append({"role": "assistant", "content": full_response})
227
 
228
 
 
197
  st.session_state.audio = False
198
 
199
 
200
+ with st.sidebar:
201
+ col1, col2 = st.columns(2)
202
+ choice = st.radio("References and TTS",["Reference" , 'TTS'])
203
+ if choice == 'Reference':
 
 
 
 
204
  generate_pdf()
205
  st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
206
+ col1.image(st.session_state['reference'])
 
 
 
207
 
208
+ if choice == 'TTS':
 
 
209
  with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
210
  tts = gTTS(result['result'], lang='en', tld = 'co.in')
211
  tts.write_to_fp(sound_file)
212
  sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
213
  sound.export("/home/user/app/audio/audio.wav", format="wav")
214
  st.session_state['audio'] = '/home/user/app/audio/audio.wav'
215
+ col2.audio(st.session_state['audio'])
216
+
217
  st.session_state.messages.append({"role": "assistant", "content": full_response})
218
 
219