From df7457c70b5af5e7c6ac6ab3743fbb1b2ffb351f Mon Sep 17 00:00:00 2001 From: Sebastian <68529971+html-proof@users.noreply.github.com> Date: Thu, 1 Sep 2022 20:39:27 +0530 Subject: [PATCH 1/2] Update main.py Just update using tkiner doc using in python --- main.py | 54 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index fdb41dd..0cb538a 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,44 @@ -import pyttsx3 import PyPDF2 -book = open('oop.pdf', 'rb') -pdfReader = PyPDF2.PdfFileReader(book) -pages = pdfReader.numPages - -speaker = pyttsx3.init() -for num in range(7, pages): - page = pdfReader.getPage(num) - text = page.extractText() - speaker.say(text) - speaker.runAndWait() +from tkinter import * +from tkinter import filedialog +import pyttsx3 +import time +win = Tk() + +win.geometry("1500x1500") +txt1 = IntVar() + +text = Text(win, width=80, height=30) +text.pack(pady=20) + +try: + def open_pdf(): + file = filedialog.askopenfilename(title="Select a PDF", filetype=(("PDF Files", "*.pdf"), ("All Files", "*.*"))) + if file: + pdf_file = PyPDF2.PdfFileReader(file) + + page = pdf_file.getPage(txt1.get()) + + content = page.extractText() + txt = pyttsx3.init() + txt.say(content) + txt.runAndWait() + text.insert(1.0, content) + time.sleep(2) + + + + +except FloatingPointError: + pass + + +bt1_open = Button(win, text="Select the file ", command=open_pdf) +lbl = Label(win, text="input the page to speak") +lbl2 = Entry(win, textvariable=txt1) +lbl.pack() +lbl2.pack() +bt1_open.pack() + + +win.mainloop() From e525d10d6fe444acf617aa4ee6a3259d39e75f8e Mon Sep 17 00:00:00 2001 From: Sebastian <68529971+html-proof@users.noreply.github.com> Date: Sat, 17 Jun 2023 20:21:28 +0530 Subject: [PATCH 2/2] Update main.py --- main.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/main.py b/main.py index 0cb538a..59b5f00 100644 --- a/main.py +++ b/main.py @@ -4,41 +4,28 @@ import pyttsx3 import time win = Tk() - win.geometry("1500x1500") txt1 = IntVar() - text = Text(win, width=80, height=30) text.pack(pady=20) - try: def open_pdf(): file = filedialog.askopenfilename(title="Select a PDF", filetype=(("PDF Files", "*.pdf"), ("All Files", "*.*"))) if file: pdf_file = PyPDF2.PdfFileReader(file) - page = pdf_file.getPage(txt1.get()) - content = page.extractText() txt = pyttsx3.init() txt.say(content) txt.runAndWait() text.insert(1.0, content) time.sleep(2) - - - - except FloatingPointError: pass - - bt1_open = Button(win, text="Select the file ", command=open_pdf) lbl = Label(win, text="input the page to speak") lbl2 = Entry(win, textvariable=txt1) lbl.pack() lbl2.pack() bt1_open.pack() - - win.mainloop()