-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpdf.py
More file actions
16 lines (13 loc) · 676 Bytes
/
pdf.py
File metadata and controls
16 lines (13 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from tkinter import Tk
from tkinter.filedialog import askopenfilename
import pdftotext
from gtts import gTTS
Tk().withdraw() # no queremos una GUI completa, así que evita que aparezca la ventana raíz
filelocation = askopenfilename() # abre el cuadro de diálogo GUI
with open(filelocation, "rb") as f: # abre el archivo en modo lectura (rb) y llámalo f
pdf = pdftotext.PDF(f) # almacenar una versión de texto del archivo pdf f en la variable pdf
string_of_text = ''
for text in pdf:
string_of_text += text
final_file = gTTS(text=string_of_text, lang='en') # almacenar archivo en variable
final_file.save("Generated Speech.mp3") # guardar archivo en la co