-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadPDF.py
More file actions
13 lines (12 loc) · 713 Bytes
/
ReadPDF.py
File metadata and controls
13 lines (12 loc) · 713 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
import pyttsx3
import PyPDF2
myPDF = open('XXXXXX.pdf', 'rb') # XXXXXX.pdf is the fileName you want to read
# rb = Read Binary as we have opened PDF file
pdfReader = PyPDF2.PdfFileReader(myPDF)
pages = pdfReader.numPages # Total number of pages in this PDF
speak = pyttsx3.init()
for number in range(22, pages): # (22, pages) --> 22 is start page till total number of pages in this PDF
page = pdfReader.getPage(number) # creating a page object
text = page.extractText() # Extract to text
speak.say(text) # Speak / say our loud the extracted text
speak.runAndWait()