sblumenf commited on
Commit
8ee8372
1 Parent(s): b99d873

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -1,14 +1,14 @@
1
  import gradio as gr
2
- import PyPDF2
3
 
4
- def extract_text_from_pdf(pdf):
5
- with open(pdf, 'rb') as pdf_file:
6
- pdf_reader = PyPDF2.PdfFileReader(pdf_file)
7
- text = ''
8
- for page in range(pdf_reader.numPages):
9
- text += pdf_reader.getPage(page).extractText()
10
  return text
11
 
12
- iface = gr.Interface(fn=extract_text_from_pdf, inputs="file", outputs="text")
 
 
 
 
13
  iface.launch()
14
-
 
1
  import gradio as gr
2
+ import pdfminer
3
 
4
+ def read_pdf(file)
5
+ from pdfminer.high_level import extract_text
6
+ text = extract_text(file.name)
 
 
 
7
  return text
8
 
9
+ iface = gr.Interface(
10
+ read_pdf,
11
+ gr.inputs.FileUpload(is_single=True, allow_pdf=True),
12
+ gr.outputs.Textbox()
13
+ )
14
  iface.launch()