pdf-chatbot / app.py
Sidharthh's picture
Update app.py
5be9cc8 verified
raw
history blame contribute delete
587 Bytes
import gradio as gr
import PyPDF2
def extract_text_from_pdf(pdf_file):
if pdf_file is None:
return "Please upload a PDF file."
reader = PyPDF2.PdfReader(pdf_file.name)
text = ""
for page in reader.pages:
text += page.extract_text() + "\n"
return text
with gr.Blocks() as demo:
gr.Markdown("### PDF Chatbot πŸ“„πŸ’¬")
pdf_input = gr.File(label="Upload your PDF")
output_text = gr.Textbox(label="Extracted Text")
pdf_input.change(fn=extract_text_from_pdf, inputs=pdf_input, outputs=output_text)
app.launch(share=True)