File size: 2,057 Bytes
948fff6
05fb365
fc3f994
 
db97d05
 
 
f06847c
56ea16f
db97d05
ad2985d
1aa3fc7
948fff6
26d106e
75831a8
 
 
f06847c
1deb6df
 
 
 
 
 
f06847c
 
 
4e40d7d
56ea16f
4e40d7d
56ea16f
4e40d7d
 
 
f2ce8a3
4e40d7d
8ba77b0
 
 
56ea16f
3815fb2
b8bc243
 
 
 
28401df
 
 
3815fb2
 
 
2453224
3815fb2
 
2453224
3815fb2
 
 
 
 
 
 
ad2985d
5409b09
 
 
 
 
 
 
d9ecfbf
 
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
import IPython.display as ipd


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)

name=""
if paper:
  name = paper.title+'.pdf'
  name = name.replace('?', '')
  name = "downloads/" + name

name = "./downloads/paper.pdf"

tpages = len(list(extract_pages(name)))
print("total pages=", tpages)
pgs = [i+1 for i in range(tpages)]
  
start_page = 1
end_page = 1
  
with st.form(key = "page_form"):
  col1, col2 = st.columns(2)
  with col1:
    s_page = st.selectbox(label = "Start Page", options = pgs)
  with col2:
    e_page = st.selectbox(label = "End Page", options = pgs, index = pgs[-1]-1)
  submit_pages = st.form_submit_button(label = "Convert To Audio")
    
if submit_pages:
  if start_page > end_page:
    st.write("Wrong Sequence, cannot process")
  else:
    content = get_pages(name, start_page, end_page)
    wav, rate = tts(content)
    ipd.Audio(wav, rate=rate)
else:
  st.write("No Paper Selected")