Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created November 15, 2020 08:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/41082a4e10d02c408679f2c9ba0a466a to your computer and use it in GitHub Desktop.
Save amankharwal/41082a4e10d02c408679f2c9ba0a466a to your computer and use it in GitHub Desktop.
import pyttsx3
import pdfplumber
import PyPDF2
file = 'C:/Users/<user_name>/Desktop/Book.pdf'
#Creating a PDF File Object
pdfFileObj = open(file, 'rb')
# creating a pdf reader object
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
#Get the number of pages
pages = pdfReader.numPages
with pdfplumber.open(file) as pdf:
#Loop through the number of pages
for i in range(0, pages):
page = pdf.pages[i]
text = page.extract_text()
print(text)
speaker = pyttsx3.init()
speaker.say(text)
speaker.runAndWait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment