Build your own Free Audio Book from PDF using Python

Hello everyone,

In this tutorial, we are going to make an Audiobook from PDF using python.  As we know we have to pay a lot of money to buy an audiobook subscription online, most of us cant able to afford that. so we can use this method to build an audiobook and listen to it.

we are using 2 dependencies to make it work. PyPDF2 and pyttsx3. The PyPDF2 dependencies help us to get the contents from the PDF file and the pyttsx3 will read that for us. simple.
let’s start writing code, for that  You need Python and the PyCharm IDE on your pc  (or you can use any of your IDE)

Download the dependencies first

pip install pypdf2

pip install pyttsx3

Now open your code editor and write this script. and copy your PDF file to the same folder as u have this file saved.

import PyPDF2 
import pyttsx3	

pdfobj = open('demo.pdf','rb')	#replace demo with your file

#pdf file object.
pdfreader = PyPDF2.PdfFileReader(pdfobj)

text = ""

#read all the page of pdf.
for pagenumber in range(pdfreader.numPages):
    page = pdfreader.getPage(pagenumber)	#get page.
    text += page.extractText()	        #extract the text.

pdfobj.close()	        #close the file.


engine = pyttsx3.init()		#init the text to speech library.
engine.say(text)		#this function speak the text.

Run the code in your terminal. and this python guy will tell you what’s inside your book.
Enjoy your audio book.

Share with your friends:

Ajith Jojo Joseph

Self taught, dedicated young entrepreneur with many licensed products under his sleeve. Passionate about technology, business and excellence in general.

HTML Form to Email Using JavaScript and SMTP server 🚀

Hello Everyone, 🙋‍♂️ In this tutorial, we are going to look at how to send emails from HTML Form to […]

22 September, 2021

How to make pretty URL in PHP using .htaccess

Hello Everyone, Here in this tutorial, you will learn How to make a pretty URL in PHP using .htaccess. and […]

18 September, 2021

Submit Form Without Refreshing Page PHP and Javascript

Hello Everyone, In this tutorial, we are going to learn, How to submit a form without reloading. yeah, that’s so […]

HTML from to Email using SMTP in PHP with Source code

Hello Everyone, In this tutorial, I am going to teach you how to send an email from an HTML form […]

16 September, 2021


Subscribe to our weekly Newsletter and stay tuned.

Free PHP Invoicing Software

Gmax CRM Lite is an Invoicing and project management tool for small businesses, features including client management , invoicing , quotation and project management

Download for free