ArXivAudio / app.py
Archan's picture
Update app.py
bb888ff
raw
history blame
1.71 kB
import streamlit as st
import arxiv
import os
#import pdfminer
#from pdfminer.high_level import extract_text, extract_pages
#from pdfminer.layout import LTTextContainer
from search import search
from get_paper import get_paper
#from get_pages import get_pages
#from tts import tts
st.title("ArXiV Audio")
with st.form(key = "search_form"):
col1, col2, col3 = st.columns(3)
with col1:
query = st.text_input("Search Paper")
with col2:
sort_by = st.selectbox(label = "Sort By", options=('Relevance', 'Last Updated Date','Submitted Date'))
with col3:
order_by = st.selectbox(label = "Order By", options=('Ascending', 'Descending'))
submit = st.form_submit_button(label = "Search")
lst = search(query=query, sort_by=sort_by, sort_order=order_by)
if len(lst) != 0:
label = "Papers for " + query
with st.form(key = "paper_form"):
pname = st.selectbox(label = label, options=lst)
submit_paper = st.form_submit_button(label = "Fetch Paper")
else:
with st.form(key = "paper_form"):
pname = st.selectbox(label = "NO PAPERS", options=lst)
submit_paper = st.form_submit_button(label = "Fetch Paper")
paper=""
if submit_paper:
paper = get_paper(pname)
if paper:
name = paper.title+'.pdf'
name = name.replace('?', '')
name = "downloads/" + name
tpages = len(list(extract_pages(name)))
print("total pages=", tpages)
pgs = [i+1 for i in range(tpages)]
with st.form(key = "page_form"):
col1, col2 = st.columns(2)
with col1:
start_page = st.selectbox(label = "Start Page", options = pgs)
with col2:
end_page = st.selectbox(label = "End Page", options = pgs)
submit_pages = st.form_submit_button(label = "Convert To Audio")