Spaces:
Runtime error
Runtime error
| 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) | |