Last active
January 18, 2022 13:15
-
-
Save JayantGoel001/108de603617aa6b8463de92a708b11bd to your computer and use it in GitHub Desktop.
Creating An Audio Book from a PDF File using pyttsx3 and PyPDF2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment