Mishmosh commited on
Commit
2f5a6c0
·
1 Parent(s): d3b5309

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -39
app.py CHANGED
@@ -1,43 +1,12 @@
1
- import gradio as gr
2
- import PyPDF2
3
- from pdfminer.high_level import extract_text
4
- import pdfplumber
5
- from pdf2image import convert_from_path
6
- from PIL import Image
7
- import pytesseract
8
- from transformers import pipeline
9
-
10
- def read_pdf(pdf_path):
11
- pdfFileObj = open(pdf_path, 'rb')
12
- pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
13
-
14
- text_per_page = {}
15
- for pagenum, page in enumerate(extract_text(pdf_path).split('\x0c')):
16
- print("Elaborating Page_" + str(pagenum))
17
- page_text = []
18
- # other variables...
19
-
20
- text_per_page[f'Page_{pagenum}'] = [page_text] # You can add other lists as needed
21
-
22
- pdfFileObj.close()
23
- return text_per_page
24
-
25
- def summarize_text(text):
26
- summarizer = pipeline("summarization", model="ainize/bart-base-cnn")
27
- return summarizer(text)
28
-
29
- def text_to_speech(text):
30
- # Add the text-to-speech code here using the provided code
31
-
32
- # Define Gradio interface
33
  iface = gr.Interface(
34
- fn=read_pdf,
35
- inputs=gr.File(),
36
- outputs=gr.Textbox(),
37
  live=True,
38
- interpretation="pdf",
39
- title="PDF Reader"
40
  )
41
 
42
- # Launch the Gradio app
43
- iface.launch()
 
1
+ # Gradio interface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  iface = gr.Interface(
3
+ fn=summarize_and_speak,
4
+ inputs=gr.File(label="Upload PDF", type="file"),
5
+ outputs="text",
6
  live=True,
7
+ title="PDF Abstract Summarizer",
8
+ description="Please upload a PDF that contains an abstract. I will provide a one-sentence summary of the abstract and will say the summary out loud."
9
  )
10
 
11
+ # Launch the interface
12
+ iface.launch()