Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,9 @@ import streamlit as st
|
|
2 |
from gtts import gTTS
|
3 |
from io import BytesIO
|
4 |
from PyPDF2 import PdfReader
|
|
|
|
|
|
|
5 |
|
6 |
st.image('OIG3 (4).jpeg', caption='Your host on this PDF-to-Speech adventure!')
|
7 |
|
@@ -22,10 +25,19 @@ if uploaded_file is not None:
|
|
22 |
# extracting text from page
|
23 |
text = page.extract_text()
|
24 |
print("Created text of page", i )
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
print("Read aloud", i, "pages of", X, "total pages.")
|
30 |
i = i + 1
|
31 |
st.write("๐ That's the whole PDF! Have an awesome day! ๐")
|
|
|
2 |
from gtts import gTTS
|
3 |
from io import BytesIO
|
4 |
from PyPDF2 import PdfReader
|
5 |
+
from whisperspeech.pipeline import Pipeline
|
6 |
+
|
7 |
+
pipe = Pipeline(torch_compile=True)
|
8 |
|
9 |
st.image('OIG3 (4).jpeg', caption='Your host on this PDF-to-Speech adventure!')
|
10 |
|
|
|
25 |
# extracting text from page
|
26 |
text = page.extract_text()
|
27 |
print("Created text of page", i )
|
28 |
+
|
29 |
+
# Generate audio for the current page using a unique filename
|
30 |
+
page_audio_file = f"output_{i}.wav"
|
31 |
+
pipe.generate_to_file(page_audio_file, text)
|
32 |
+
|
33 |
+
# Display the generated audio using st.audio
|
34 |
+
with open(page_audio_file, "rb") as audio_file:
|
35 |
+
st.audio(audio_file)
|
36 |
+
|
37 |
+
# sound_file = BytesIO()
|
38 |
+
# tts = gTTS(text, lang='en')
|
39 |
+
# tts.write_to_fp(sound_file)
|
40 |
+
# st.audio(sound_file)
|
41 |
print("Read aloud", i, "pages of", X, "total pages.")
|
42 |
i = i + 1
|
43 |
st.write("๐ That's the whole PDF! Have an awesome day! ๐")
|