Ignir commited on
Commit
01d40bc
·
1 Parent(s): 789f552

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from gtts import gTTS
3
+ from PyPDF2 import PdfFileReader
4
+
5
+
6
+ def pdf_to_audio(file):
7
+ pdf = PdfFileReader(file)
8
+ text = ""
9
+ for page in range(pdf.getNumPages()):
10
+ text += pdf.getPage(page).extractText()
11
+ tts = gTTS(text)
12
+ audio_file = "output.mp3"
13
+ tts.save(audio_file)
14
+ return audio_file
15
+
16
+
17
+ iface = gr.Interface(fn=pdf_to_audio, inputs="file", outputs="audio")
18
+ iface.launch()