pdf_upload / app.py
Richard Hsu
push
9a0b9e9
raw
history blame
501 Bytes
import gradio as gr
from langchain.document_loaders import PyPDFLoader
def pdf_to_text(pdf_file):
loader = PyPDFLoader(pdf_file.name)
documents = loader.load()
text = "\n".join([doc.page_content for doc in documents])
print(text) # Log the loaded text
return text
def pdf_to_text_interface(pdf_file):
text = pdf_to_text(pdf_file)
return text
iface = gr.Interface(fn=pdf_to_text_interface, inputs="file", outputs="text", title="PDF to Text Converter <3")
iface.launch()