Solshine's picture
Update app.py
e055bb5 verified
raw
history blame
1.16 kB
import streamlit as st
from gtts import gTTS
from io import BytesIO
from io import StringIO
from pdfminer.pdfinterp import PDFResourceManager, process_pdf
from pdfminer.converter import TextConverter
from pdfminer.layout import LAParams
x = st.slider('Select a value')
slider_reply = x, 'squared is', x * x
st.write(slider_reply)
uploaded_file = st.file_uploader("Choose a file", "pdf")
if uploaded_file is not None:
input_ = file(uploaded_file, 'rb')
output = StringIO()
manager = PDFResourceManager()
converter = TextConverter(manager, output, laparams=LAParams())
process_pdf(manager, converter, input_)
element = output.getvalue()
st.write(element)
with st.popover("Open popover"):
sound_file = BytesIO()
tts = gTTS(element, lang='en')
tts.write_to_fp(sound_file)
st.audio(sound_file)
prompt = st.chat_input("Say something")
if prompt:
st.write(prompt)
with st.popover("Open popover"):
sound_file = BytesIO()
tts = gTTS(prompt, lang='en')
tts.write_to_fp(sound_file)
st.audio(sound_file)