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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -11
app.py CHANGED
@@ -195,9 +195,15 @@ if prompt := st.chat_input("How can I help you today?"):
195
  if "audio" not in st.session_state:
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()
@@ -209,15 +215,16 @@ if prompt := st.chat_input("How can I help you today?"):
209
  # st.session_state['audio'] = '/home/user/app/audio/audio.wav'
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
 
 
195
  if "audio" not in st.session_state:
196
  st.session_state.audio = False
197
 
198
+
199
+ if st.button('Reference'):
200
+ with st.sidebar:
201
+ generate_pdf()
202
+ st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
203
+ st.image(st.session_state['reference'])
204
+
205
  #choice = st.radio("References and TTS",["Reference" , 'TTS'])
206
+ #choice = st.radio("References and TTS",['TTS'])
207
 
208
  # if choice == 'Reference':
209
  # generate_pdf()
 
215
  # st.session_state['audio'] = '/home/user/app/audio/audio.wav'
216
  # st.audio(st.session_state['audio'])
217
 
218
+ if st.button('TTS'):
219
+ with st.sidebar:
220
+ with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
221
+ #sound_file = BytesIO()
222
+ tts = gTTS(result['result'], lang='en', tld = 'co.in')
223
+ tts.write_to_fp(sound_file)
224
+ sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
225
+ sound.export("/home/user/app/audio/audio.wav", format="wav")
226
+ st.session_state['audio'] = '/home/user/app/audio/audio.wav'
227
+ st.audio(st.session_state['audio'])
228
 
229
  st.session_state.messages.append({"role": "assistant", "content": full_response})
230