File size: 1,166 Bytes
1a7973f
9853375
1a7973f
 
9853375
fac92f6
d6da658
1a7973f
 
 
 
 
 
 
 
 
 
 
 
fac92f6
1a7973f
 
 
 
 
 
 
 
 
 
 
 
5c5a283
9853375
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
from gtts import gTTS
from pdfminer.high_level import extract_text
import gradio as gr
import os


def pdf_to_text(file_obj):
    text = extract_text(file_obj.name)
    myobj = gTTS(text=text, lang='en', slow=False) 
    myobj.save("test.wav") 
    return 'test.wav'


examples = [
    [os.path.abspath("short-pdf.pdf")],
    [os.path.abspath("long-pdf.pdf")]
]


iface = gr.Interface(fn = pdf_to_text,
                     inputs = 'file',
                     outputs = 'audio', 
                     verbose = True,
                     title = 'PDF to Audio Application',
                     description = 'A simple application to convert PDF files in audio speech. Upload your own file, or click one of the examples to load them.',
                     article = 
                        '''<div>
                            <p style="text-align: center"> All you need to do is to upload the pdf file and hit submit, then wait for compiling. After that click on Play/Pause for listing to the audio. The audio is saved in a wav format.</p>
                        </div>''',
                     examples=examples
                    )

iface.launch()