PDF-to-text / app.py
sblumenf's picture
Update app.py
21813ce
raw
history blame
492 Bytes
import gradio as gr
from io import BytesIO
from pdfminer.high_level import extract_text
import requests
def read_pdf(file):
if isinstance(file, str):
if file.startswith('http'):
file = BytesIO(requests.get(file).content)
text = extract_text(file)
return text
iface = gr.Interface(fn=read_pdf, inputs="file", outputs="text",
title="PDF Text Extractor",
description="Extract text from a PDF file.")
iface.launch()