Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,25 @@
|
|
1 |
import streamlit as st
|
2 |
from gtts import gTTS
|
3 |
from io import BytesIO
|
4 |
-
import
|
5 |
|
6 |
x = st.slider('Select a value')
|
7 |
slider_reply = x, 'squared is', x * x
|
8 |
st.write(slider_reply)
|
9 |
|
10 |
uploaded_file = st.file_uploader("Choose a file", "pdf")
|
11 |
-
if uploaded_file is not None:
|
12 |
-
|
|
|
|
|
|
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
element+=page.get_text()
|
18 |
-
|
19 |
-
element = output.getvalue()
|
20 |
-
print("Created element")
|
21 |
with st.popover("Open popover"):
|
22 |
sound_file = BytesIO()
|
23 |
-
tts = gTTS(
|
24 |
tts.write_to_fp(sound_file)
|
25 |
|
26 |
st.audio(sound_file)
|
|
|
1 |
import streamlit as st
|
2 |
from gtts import gTTS
|
3 |
from io import BytesIO
|
4 |
+
from PyPDF2 import PdfReader
|
5 |
|
6 |
x = st.slider('Select a value')
|
7 |
slider_reply = x, 'squared is', x * x
|
8 |
st.write(slider_reply)
|
9 |
|
10 |
uploaded_file = st.file_uploader("Choose a file", "pdf")
|
11 |
+
if uploaded_file is not None:
|
12 |
+
# creating a pdf reader object
|
13 |
+
reader = PdfReader(uploaded_file)
|
14 |
+
# getting a specific page from the pdf file
|
15 |
+
pages = reader.pages
|
16 |
|
17 |
+
# extracting text from page
|
18 |
+
text = page.extract_text()
|
19 |
+
print("Created text")
|
|
|
|
|
|
|
|
|
20 |
with st.popover("Open popover"):
|
21 |
sound_file = BytesIO()
|
22 |
+
tts = gTTS(text, lang='en')
|
23 |
tts.write_to_fp(sound_file)
|
24 |
|
25 |
st.audio(sound_file)
|