sblumenf commited on
Commit
8b8735d
1 Parent(s): 4391bc2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from io import BytesIO
3
+ from pdfminer.high_level import extract_text
4
+ import requests
5
+
6
+ def read_pdf(file):
7
+ if isinstance(file, str):
8
+ if file.startswith('http'):
9
+ file = BytesIO(requests.get(file).content)
10
+ text = extract_text(file)
11
+ return text
12
+
13
+ iface = gr.Interface(fn=read_pdf, inputs="file_upload", outputs="text",
14
+ title="PDF Text Extractor",
15
+ description="Extract text from a PDF file.")
16
+ iface.launch()