Skip to content

Instantly share code, notes, and snippets.

@salma71
Last active January 26, 2021 23:58
Show Gist options
  • Save salma71/570d2d35cbd69988197a67851825a0e2 to your computer and use it in GitHub Desktop.
Save salma71/570d2d35cbd69988197a67851825a0e2 to your computer and use it in GitHub Desktop.
from gtts import gTTS
from pdfminer.high_level import extract_text
import gradio as gr
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',
title = 'PDF into speech Application',
description = 'Simple application in python to try the Gradio package components',
article =
'''<div>
<p> 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 listening to the audio. The audio is saved in a wav format.</p>
</div>'''
)
iface.launch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment