File size: 1,713 Bytes
948fff6
05fb365
fc3f994
 
8f6e80e
 
 
f06847c
56ea16f
8f6e80e
 
948fff6
26d106e
75831a8
 
 
f06847c
1deb6df
 
 
 
 
 
f06847c
 
 
4e40d7d
56ea16f
4e40d7d
56ea16f
4e40d7d
 
 
f2ce8a3
4e40d7d
8ba77b0
 
 
56ea16f
b8bc243
 
 
 
 
 
 
 
8230845
 
 
 
 
 
 
4e40d7d
6c30eeb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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")