Spaces:
Runtime error
Runtime error
File size: 871 Bytes
5cddb5b 19fe8c6 5cddb5b 749ef8a 7ada40b 5cddb5b a6b5bfa 5cddb5b 7956ef6 5cddb5b 7956ef6 5cddb5b 4f4f257 5cddb5b |
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 35 36 37 38 39 40 |
#**************** IMPORT PACKAGES ********************
import gradio as gr
import numpy as np
import os
import re
import tempfile
from zipfile import ZipFile
pip install gtts
pip install pdfminer.six
from gtts import gTTS
from pdfminer.high_level import extract_text
def pdf_to_text(text, PDF):
if text == "":
# The setup of huggingface.co
file_obj = PDF
#n = int(Percent.replace('%', ''))
text = extract_text(file_obj.name)
outpit_text = text
else:
output_text = text
# Generate Summary
myobj = gTTS(text=output_text, lang='en', slow=False)
myobj.save("audio.wav")
return "audio.wav"
# return path
#pageObject.extractText()
iface = gr.Interface(fn = pdf_to_text,
inputs =["text", "file"], outputs=["audio"] )
if __name__ == "__main__":
iface.launch(share=True) |