Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions pdfreader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import all the needed packages
import sys
import pyttsx3
import PyPDF2
Expand All @@ -9,44 +10,45 @@
#matter = files.read()
#print (matter)

pdfFileObj = open(path, 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
a=pdfReader.numPages
print(a)
pdfFileObj = open(path, 'rb') #open the the need pdf file path
pdfReader = PyPDF2.PdfFileReader(pdfFileObj) #read the pdf file path
a=pdfReader.numPages #find the number of pages in the file path
print(a) #print the number of pages
x=1
c=1

#Reads the PDF

def read(page):
def read(page): #create the read pdf function

page_content= pdfReader.getPage(int(page))
b = page_content.extractText()
print(b)
page_content= pdfReader.getPage(int(page)) #get the needed page index
b = page_content.extractText() #collect text of pdf and store in variable b
print(b) #print the text of the pdf
#begin runing the text to speach function
engine = pyttsx3.init()
rate = engine.getProperty('rate')
engine.setProperty('rate', rate-50)
engine.say(b)
engine.say("Page number "+str(page)+" is completed")
engine.say("Page number "+str(page)+" is completed") #display when the page is done
engine.runAndWait()
engine.stop()

# The main code
while(x):
page = input("Enter the page number to read :")
read(page)
c=int(input("Do you want to continue? (1)Yess (2)No"))
if(c==2):
while(x): #start the while function to read the pdf continously
page = input("Enter the page number to read :") #ask the user for the page read desired

read(page) #calls the read function and passes in the users desired page to read
c=int(input("Do you want to continue? (1)Yess (2)No")) #ask the user to continue
if(c==2): #if the user picks (2)No then the x variable then becomes 0 and the while function stops
x=0
print("Thank you")














Expand Down