Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
from pdfminer.high_level import extract_text
|
4 |
-
import requests
|
5 |
|
6 |
-
def
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
11 |
return text
|
12 |
|
13 |
-
iface = gr.Interface(fn=
|
14 |
-
title="PDF Text Extractor",
|
15 |
-
description="Extract text from a PDF file.")
|
16 |
iface.launch()
|
|
|
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()
|