File size: 500 Bytes
8b8735d
8ee8372
6bba4b2
a69dbfc
8b8735d
a69dbfc
 
 
 
 
 
 
8b8735d
 
8ee8372
 
cfb68d1
a69dbfc
8ee8372
 
8b8735d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
import pdfminer
from pdfminer.high_level import extract_text
import urllib.request

def read_pdf(file=None, url=None):
    if file:
        text = extract_text(file.name)
    elif url:
        response = urllib.request.urlopen(url)
        file = response.read()
        text = extract_text(file)
    return text

iface = gr.Interface(
    read_pdf,
    gr.inputs.File(),
    gr.inputs.Textbox(prompt="Enter a URL that points to a pdf"),
    gr.outputs.Textbox()
)
iface.launch()