Create audiobook from PDF using Python with Source code

Delve into the world of audio and literature as we guide you through the creation of an audiobook from a PDF document using Python. We’re excited to provide you with the complete source code to transform your written content into engaging spoken narratives, making literature more accessible and enjoyable than ever.

# Import the necessary modules!
import pyttsx3
import PyPDF2

# Open our file in reading format and store into book
book = open('demo.pdf','rb')    # `rb` stands for reading mode

pdf_reader = PyPDF2.PdfFileReader(book)

num_pages = pdf_reader.numPages

play = pyttsx3.init()
print('Playing Audio Book')

for num in range(0, num_pages):
    page = pdf_reader.getPage(num)
    # Extract the text from our page using extractText method on our page and store it into data.
    data = page.extractText()


Leave a Reply