PDF-to-text / app.py
sblumenf's picture
Create app.py
8b8735d
raw
history blame
499 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_upload", outputs="text",
title="PDF Text Extractor",
description="Extract text from a PDF file.")
iface.launch()