Update app.py
Browse files
app.py
CHANGED
|
@@ -196,23 +196,23 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
| 196 |
if "audio" not in st.session_state:
|
| 197 |
st.session_state.audio = False
|
| 198 |
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
if choice == 'Reference':
|
| 204 |
generate_pdf()
|
| 205 |
st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
|
| 206 |
-
|
| 207 |
|
| 208 |
-
|
|
|
|
| 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 |
-
|
| 216 |
|
| 217 |
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
| 218 |
|
|
|
|
| 196 |
if "audio" not in st.session_state:
|
| 197 |
st.session_state.audio = False
|
| 198 |
|
| 199 |
+
choice = st.radio("References and TTS",["Reference" , 'TTS'], index='None')
|
| 200 |
+
|
| 201 |
+
if choice == 'Reference':
|
| 202 |
+
with st.sidebar:
|
|
|
|
| 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 |
+
with st.sidebar:
|
| 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 |
+
st.audio(st.session_state['audio'])
|
| 216 |
|
| 217 |
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
| 218 |
|