Skip to content

Instantly share code, notes, and snippets.

@JayantGoel001
Last active January 18, 2022 13:15
Show Gist options
  • Save JayantGoel001/108de603617aa6b8463de92a708b11bd to your computer and use it in GitHub Desktop.
Save JayantGoel001/108de603617aa6b8463de92a708b11bd to your computer and use it in GitHub Desktop.
Creating An Audio Book from a PDF File using pyttsx3 and PyPDF2
import pyttsx3
import PyPDF2
book = open('poem.pdf', 'rb')
pdf_reader = PyPDF2.PdfFileReader(book)
num_pages = pdf_reader.numPages
play = pyttsx3.init()
print("Play the audio book")
for num in range(num_pages):
page = pdf_reader.getPage(num)
data = page.extractText()
play.say(data)
play.runAndWait()
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment