Spaces:
Runtime error
Runtime error
Changes to allocate the error
Browse files
app.py
CHANGED
@@ -1,95 +1,94 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import arxiv
|
3 |
-
|
4 |
import os
|
5 |
-
import
|
6 |
-
from pdfminer.high_level import
|
7 |
-
from pdfminer.layout import LTTextContainer
|
8 |
from search import search
|
9 |
from get_paper import get_paper
|
10 |
from get_pages import get_pages
|
11 |
from tts import inference
|
12 |
-
import IPython.display as ipd
|
13 |
|
14 |
st.title("ArXiV Audio")
|
15 |
|
16 |
-
with st.form(key
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
26 |
lst = search(query=query, sort_by=sort_by, sort_order=order_by)
|
27 |
if len(lst) != 0:
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
else:
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
#content = get_pages(name, start_page, end_page)
|
55 |
#audio_path = inference(content, "english")
|
56 |
#audio_file = open(audio_path, "rb")
|
57 |
#audio_bytes = audio_file.read()
|
58 |
#st.audio(audio_bytes, format='audio/wav')
|
59 |
-
|
60 |
-
with st.form(key = "page_form"):
|
61 |
-
print("inside page form")
|
62 |
-
col4, col5 = st.columns(2)
|
63 |
-
with col4:
|
64 |
-
print("column 1")
|
65 |
-
s_page = st.selectbox(label = "Start Page", options = pgs)
|
66 |
-
print(s_page)
|
67 |
-
start_page = s_page
|
68 |
-
with col5:
|
69 |
-
print("column 2")
|
70 |
-
e_page = st.selectbox(label = "End Page", options = pgs, index = lst_idx)
|
71 |
-
print(e_page)
|
72 |
-
end_page = e_page
|
73 |
-
submit_pages = st.form_submit_button(label = "Convert To Audio")
|
74 |
-
print("Submit_pages' = ", submit_pages)
|
75 |
-
print(start_page, end_page)
|
76 |
-
|
77 |
-
print("Submit_pages = ", submit_pages)
|
78 |
-
if submit_pages:
|
79 |
-
content = get_pages(name, start_page, end_page)
|
80 |
-
audio_path = inference(content, "english")
|
81 |
-
audio_file = open(audio_path, "rb")
|
82 |
-
audio_bytes = audio_file.read()
|
83 |
-
st.audio(audio_bytes, format='audio/wav')
|
84 |
-
|
85 |
-
print("Submit_paper at end state = ", submit_paper)
|
86 |
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
else:
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
+
import streamlit as st
|
3 |
+
from pdfminer.high_level import extract_pages
|
|
|
4 |
from search import search
|
5 |
from get_paper import get_paper
|
6 |
from get_pages import get_pages
|
7 |
from tts import inference
|
|
|
8 |
|
9 |
st.title("ArXiV Audio")
|
10 |
|
11 |
+
with st.form(key="search_form"):
|
12 |
+
col1, col2, col3 = st.columns(3)
|
13 |
+
with col1:
|
14 |
+
query = st.text_input("Search Paper")
|
15 |
+
with col2:
|
16 |
+
sort_by = st.selectbox(label="Sort By", options=(
|
17 |
+
'Relevance', 'Last Updated Date', 'Submitted Date'))
|
18 |
+
with col3:
|
19 |
+
order_by = st.selectbox(
|
20 |
+
label="Order By", options=('Ascending', 'Descending'))
|
21 |
+
submit = st.form_submit_button(label="Search")
|
22 |
+
|
23 |
lst = search(query=query, sort_by=sort_by, sort_order=order_by)
|
24 |
if len(lst) != 0:
|
25 |
+
label = "Papers for " + query
|
26 |
+
with st.form(key="paper_form"):
|
27 |
+
pname = st.selectbox(label=label, options=lst)
|
28 |
+
submit_paper = st.form_submit_button(label="Fetch Paper")
|
29 |
else:
|
30 |
+
with st.form(key="paper_form"):
|
31 |
+
pname = st.selectbox(label="NO PAPERS", options=lst)
|
32 |
+
submit_paper = st.form_submit_button(label="Fetch Paper")
|
33 |
+
|
34 |
+
paper = ""
|
35 |
+
if submit_paper or os.path.exists('downloads/paper.pdf'):
|
36 |
+
paper = get_paper(pname)
|
37 |
+
|
38 |
+
print("Submit_paper = ", submit_paper)
|
39 |
|
40 |
+
name = ""
|
41 |
+
tpages = 0
|
42 |
+
lst_idx = 1
|
43 |
+
if paper:
|
44 |
+
name = "./downloads/paper.pdf"
|
45 |
+
tpages = len(list(extract_pages(name)))
|
46 |
+
lst_idx = tpages-1
|
47 |
+
|
48 |
+
pgs = [i+1 for i in range(tpages)]
|
49 |
+
|
50 |
+
start_page = 1
|
51 |
+
end_page = pgs[-1]
|
52 |
#content = get_pages(name, start_page, end_page)
|
53 |
#audio_path = inference(content, "english")
|
54 |
#audio_file = open(audio_path, "rb")
|
55 |
#audio_bytes = audio_file.read()
|
56 |
#st.audio(audio_bytes, format='audio/wav')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
+
with st.form(key="page_form"):
|
59 |
+
print("inside page form")
|
60 |
+
col4, col5 = st.columns(2)
|
61 |
+
with col4:
|
62 |
+
print("column 1")
|
63 |
+
s_page = st.selectbox(label="Start Page", options=pgs)
|
64 |
+
print(s_page)
|
65 |
+
start_page = s_page
|
66 |
+
with col5:
|
67 |
+
print("column 2")
|
68 |
+
e_page = st.selectbox(label="End Page", options=pgs, index=lst_idx)
|
69 |
+
print(e_page)
|
70 |
+
end_page = e_page
|
71 |
+
submit_pages = st.form_submit_button(label="Convert To Audio")
|
72 |
+
print("Submit_pages' = ", submit_pages)
|
73 |
+
print(start_page, end_page)
|
74 |
+
|
75 |
+
print("Submit_pages = ", submit_pages)
|
76 |
+
if submit_pages:
|
77 |
+
content = get_pages(name, start_page, end_page)
|
78 |
+
audio_path = inference(content, "english")
|
79 |
+
audio_file = open(audio_path, "rb")
|
80 |
+
audio_bytes = audio_file.read()
|
81 |
+
st.audio(audio_bytes, format='audio/wav')
|
82 |
+
os.remove('downloads/paper.pdf')
|
83 |
+
|
84 |
+
print("Submit_paper at end state = ", submit_paper)
|
85 |
+
|
86 |
+
|
87 |
else:
|
88 |
+
with st.form(key="page_form"):
|
89 |
+
col1, col2 = st.columns(2)
|
90 |
+
with col1:
|
91 |
+
s_page = st.selectbox(label="Start Page", options=[])
|
92 |
+
with col2:
|
93 |
+
e_page = st.selectbox(label="End Page", options=[])
|
94 |
+
submit_pages2 = st.form_submit_button(label="Convert To Audio")
|
tts.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
-
import time
|
2 |
import torch
|
3 |
import scipy.io.wavfile
|
4 |
from espnet2.bin.tts_inference import Text2Speech
|
5 |
from espnet2.utils.types import str_or_none
|
6 |
|
7 |
-
tagen = 'kan-bayashi/ljspeech_vits'
|
8 |
-
vocoder_tagen = "none"
|
9 |
|
10 |
text2speechen = Text2Speech.from_pretrained(
|
11 |
model_tag=str_or_none(tagen),
|
@@ -27,10 +26,11 @@ text2speechen = Text2Speech.from_pretrained(
|
|
27 |
)
|
28 |
|
29 |
|
30 |
-
def inference(text,lang):
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
1 |
import torch
|
2 |
import scipy.io.wavfile
|
3 |
from espnet2.bin.tts_inference import Text2Speech
|
4 |
from espnet2.utils.types import str_or_none
|
5 |
|
6 |
+
tagen = 'kan-bayashi/ljspeech_vits'
|
7 |
+
vocoder_tagen = "none"
|
8 |
|
9 |
text2speechen = Text2Speech.from_pretrained(
|
10 |
model_tag=str_or_none(tagen),
|
|
|
26 |
)
|
27 |
|
28 |
|
29 |
+
def inference(text, lang):
|
30 |
+
print("Converting to Audio")
|
31 |
+
with torch.no_grad():
|
32 |
+
if lang == "english":
|
33 |
+
wav = text2speechen(text)["wav"]
|
34 |
+
scipy.io.wavfile.write(
|
35 |
+
"./audio/out.wav", text2speechen.fs, wav.view(-1).cpu().numpy())
|
36 |
+
return "./audio/out.wav"
|