vishwask commited on
Commit
26406c9
·
1 Parent(s): dd79c05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -85
app.py CHANGED
@@ -186,91 +186,30 @@ if prompt := st.chat_input("How can I help you today?"):
186
  sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
187
  sound.export("/home/user/app/audio/audio.wav", format="wav")
188
 
189
- # st.session_state['reference'] = '/home/user/app/pdf2image/default_output.png'
190
- # st.session_state['audio'] = ''
191
-
192
-
193
-
194
-
195
- # if "reference" not in st.session_state:
196
- # st.session_state.reference = False
197
- # if "audio" not in st.session_state:
198
- # st.session_state.audio = False
199
-
200
- # #choice = st.radio(label ="References and TTS", options =["Reference" , 'TTS'])
201
-
202
- # if 'onr' not in st.session_state:
203
- # st.session_state.onr = False
204
-
205
- # def click_button_onr():
206
- # st.session_state.onr = True
207
- # if st.session_state.onr:
208
- # with st.sidebar:
209
- # st.write('ref')
210
- # generate_pdf()
211
- # st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
212
- # st.image(st.session_state['reference'])
213
-
214
- # st.button('Ref', on_click=click_button_onr)
215
-
216
-
217
-
218
- #onr = st.toggle('Reference',key='onr')
219
- #if choice == 'Reference':
220
- #if onr:
221
- # st.session_state['onr'] = True
222
- # with st.sidebar:
223
- # generate_pdf()
224
- # st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
225
- # st.image(st.session_state['reference'])
226
-
227
-
228
- # if 'ontts' not in st.session_state:
229
- # st.session_state.ontts = False
230
-
231
- # def click_button_ontts():
232
- # st.session_state.ontts = True
233
- # if st.session_state.ontts:
234
- # with st.sidebar:
235
- # st.write('audio')
236
- # with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
237
- # tts = gTTS(result['result'], lang='en', tld = 'co.in')
238
- # tts.write_to_fp(sound_file)
239
- # sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
240
- # sound.export("/home/user/app/audio/audio.wav", format="wav")
241
- # st.session_state['audio'] = '/home/user/app/audio/audio.wav'
242
- # st.audio(st.session_state['audio'])
243
-
244
- # st.button('Audio', on_click=click_button_ontts)
245
-
246
-
247
- if button('Reference', key = 'button2'):
248
- generate_pdf()
249
- #st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
250
- st.image('/home/user/app/pdf2image/output.png')
251
- if button('TTS', key = 'button3'):
252
- with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
253
- tts = gTTS(result['result'], lang='en', tld = 'co.in')
254
- tts.write_to_fp(sound_file)
255
- sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
256
- sound.export("/home/user/app/audio/audio.wav", format="wav")
257
- #st.session_state['audio'] = '/home/user/app/audio/audio.wav'
258
- st.audio('/home/user/app/audio/audio.wav')
259
-
260
-
261
-
262
-
263
- # ontts = st.toggle('Audio')
264
- # #if choice == 'TTS':
265
- # if ontts:
266
- # with st.sidebar:
267
- # with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
268
- # tts = gTTS(result['result'], lang='en', tld = 'co.in')
269
- # tts.write_to_fp(sound_file)
270
- # sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
271
- # sound.export("/home/user/app/audio/audio.wav", format="wav")
272
- # st.session_state['audio'] = '/home/user/app/audio/audio.wav'
273
- # st.audio(st.session_state['audio'])
274
 
275
  st.session_state.messages.append({"role": "assistant", "content": full_response})
276
 
 
186
  sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
187
  sound.export("/home/user/app/audio/audio.wav", format="wav")
188
 
189
+ if "reference" not in st.session_state:
190
+ st.session_state.reference = False
191
+ if "audio" not in st.session_state:
192
+ st.session_state.audio = False
193
+
194
+
195
+ with st.sidebar:
196
+ choice = st.radio("References and TTS",["Reference" , 'TTS'])
197
+
198
+ if choice == 'Reference':
199
+ st.session_state['audio'] = True
200
+ generate_pdf()
201
+ st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
202
+ st.image(st.session_state['reference'])
203
+
204
+ if choice == 'TTS':
205
+ st.session_state.reference = True
206
+ with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
207
+ tts = gTTS(result['result'], lang='en', tld = 'co.in')
208
+ tts.write_to_fp(sound_file)
209
+ sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
210
+ sound.export("/home/user/app/audio/audio.wav", format="wav")
211
+ st.session_state['audio'] = '/home/user/app/audio/audio.wav'
212
+ st.audio(st.session_state['audio'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
 
214
  st.session_state.messages.append({"role": "assistant", "content": full_response})
215