Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,7 @@ from PIL import Image
|
|
24 |
from langchain.vectorstores import FAISS
|
25 |
import transformers
|
26 |
from pydub import AudioSegment
|
|
|
27 |
|
28 |
user_session_id = uuid.uuid4()
|
29 |
|
@@ -185,32 +186,32 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
185 |
sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
|
186 |
sound.export("/home/user/app/audio/audio.wav", format="wav")
|
187 |
|
188 |
-
st.session_state['reference'] = '/home/user/app/pdf2image/default_output.png'
|
189 |
-
st.session_state['audio'] = ''
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
-
if "reference" not in st.session_state:
|
195 |
-
|
196 |
-
if "audio" not in st.session_state:
|
197 |
-
|
198 |
|
199 |
-
#choice = st.radio(label ="References and TTS", options =["Reference" , 'TTS'])
|
200 |
|
201 |
-
if 'onr' not in st.session_state:
|
202 |
-
|
203 |
|
204 |
-
def click_button_onr():
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
|
213 |
-
st.button('Ref', on_click=click_button_onr)
|
214 |
|
215 |
|
216 |
|
@@ -224,24 +225,40 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
224 |
# st.image(st.session_state['reference'])
|
225 |
|
226 |
|
227 |
-
if 'ontts' not in st.session_state:
|
228 |
-
|
229 |
|
230 |
-
def click_button_ontts():
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
|
243 |
-
st.button('Audio', on_click=click_button_ontts)
|
244 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
|
247 |
|
|
|
24 |
from langchain.vectorstores import FAISS
|
25 |
import transformers
|
26 |
from pydub import AudioSegment
|
27 |
+
from streamlit_extras.stateful_button import button
|
28 |
|
29 |
user_session_id = uuid.uuid4()
|
30 |
|
|
|
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 |
|
|
|
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 |
+
if button('Reference and TTS'):
|
247 |
+
if button('Reference'):
|
248 |
+
with st.sidebar:
|
249 |
+
generate_pdf()
|
250 |
+
st.session_state['reference'] = '/home/user/app/pdf2image/output.png'
|
251 |
+
st.image(st.session_state['reference'])
|
252 |
+
if button('TTS'):
|
253 |
+
with st.sidebar:
|
254 |
+
with open('/home/user/app/audio/audio.mp3','wb') as sound_file:
|
255 |
+
tts = gTTS(result['result'], lang='en', tld = 'co.in')
|
256 |
+
tts.write_to_fp(sound_file)
|
257 |
+
sound = AudioSegment.from_mp3("/home/user/app/audio/audio.mp3")
|
258 |
+
sound.export("/home/user/app/audio/audio.wav", format="wav")
|
259 |
+
st.session_state['audio'] = '/home/user/app/audio/audio.wav'
|
260 |
+
st.audio(st.session_state['audio'])
|
261 |
+
|
262 |
|
263 |
|
264 |
|