Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 213 |
-
with
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
|
|
|
| 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 |
|