-
Notifications
You must be signed in to change notification settings - Fork 0
/
audiobook-gui.py
31 lines (28 loc) · 999 Bytes
/
audiobook-gui.py
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
import tkinter as tk
from tkinter import *
import PyPDF2
import pyttsx3
from tkinter import filedialog
def browse():
global pdfReader
file= filedialog.askopenfilename(title="Select a PDF", filetypes=(("PDF Files","*.pdf"),("All Files","*.*")))
pdfReader = PyPDF2.PdfFileReader(open(file, 'rb'))
pathlabel.config(text=file)#configuring the pathlabel Label
def save():
global speaker
speaker = pyttsx3.init()
for page_num in range(pdfReader.numPages):
text = pdfReader.getPage(page_num).extractText()
speaker.say(text)
speaker.runAndWait()
speaker.stop()
root = Tk()#creating GUI window
root.geometry('400x150')#geometry of window
root.configure(bg='green')
root.title("HULK Office: AudioBook")#title of window
Label(root, text="AUDIOBOOK",font="Arial 15",bg='white').pack()
pathlabel = Label(root)
pathlabel.pack()
Button(root,text="Browse A File",command=browse).pack()
Button(root,text="Make Him Say",command=save).pack()
root.mainloop()