Create your own Audiobook from any pdf with Python

Search for a command to run...

Do you want to play a fun game with the feeling of conquering difficult things? Slope 3 is a rewarding game that is not only healthy for children but also a challenge that adults want to conquer
By collecting the data which is coming, you as an expert from IrelandEssay.com with the help of technology is just enabling you to make tangible decisions to improve quality in product creation like forecasting the daily income of patients and improving patient engagement with respect to its own good etc.
......
I wish I could create my own audiobook (for free) and not pay hundreds of dollars for that. I mean, I can do my own voiceover, but I am not skilled in coding, etc. I have an idea to create an audiobook about numerology and the 1212 angel number in particular..but how? Where to start?
Glad you liked it 🙂
thankyou
I tried to run your program, as you can see it.
But unfortunately it is throwing me this error.
Help needed. What's wrong.
The series content will mostly cover Technical Python tutorials and my recent learnings and experience in Python.
Hi everyone, In this tutorial, I am going to teach you how to build your own digital clock with Python. We will use Tkinter to do the same. You can refer to my YouTube video tutorial for a better understanding. https://youtu.be/Cw206ZAUW6Y Repository...
All you need to know about Hacktoberfest 2021

Hello reader! Well, Hacktoberfest is something, you are gonna hear a lot about in the coming month. You can refer to my YouTube video Tutorial to see a working tutorial for better understanding and a step-by-step guide of the same. https://www.yo...

Hello reader! In this Blog post, I will share some useful code snippets and functions in Python. Give it a read. Let's get started! 1. Memory The method getsizeof can be used to retrieve the size of any object. Here's an example of the same. import...

Hello reader! Whenever a client sends a request to the server, the response always contains a status code. You might not see it always but it's returned at every client-server interaction. Well, even if you are not a programmer, you would still know...

Hello reader! Microsoft subsidiary GitHub launched Copilot to power pair programming with AI. In this blog post, I will share all you need to know about it. You can refer to my YouTube video Tutorial to see a working tutorial for better understandin...

Do you read books? Do you like listening to Audiobooks? Do you wish to create your own Audiobook from any pdf? Here's how you can do it.
You can also follow along with the video tutorial of the same!
Repository for Ultimate Resource in python. Drop a star if you find it useful! Got anything to add? Open a PR on the same!
Its time to code!
You can find the code at my GitHub Repository
First, we need to install the necessary libraries. We require two libraries to build Audiobook using Python.
A Pure-Python library built as a PDF toolkit. It is capable of extracting document information splitting documents page by page merging documents page by page cropping pages merging multiple pages into a single page encrypting and decrypting PDF files and more!
So open your terminal and run the following command.
pip install PyPDF2
If you wish to know more about it, you can refer to the documentation.
pyttsx3 is a text-to-speech conversion library in Python. Unlike alternative libraries, it works offline, and is compatible with both Python 2 and 3.
So open your terminal and run the following command.
pip install pyttsx3
If you wish to know more about it, you can refer to the documentation.
Now that we have installed the packages, we can import them in our program.
import pyttsx3
import PyPDF2
Now we need to open our file in reading format and store into book. The name of my pdf file is demo.pdf. rb stands for reading mode.
book = open('demo.pdf','rb')
Now I will call PyPDF2's PdfFileReader method on book and store it into pdf_reader
pdf_reader = PyPDF2.PdfFileReader(book)
Now let's calculate the number of pages in our pdf by using numPages method on pdf_reader and store in num_pages.
num_pages = pdf_reader.numPages
Now let's initialize pyttsx3 using init method and let's print playing Audiobook
play = pyttsx3.init()
print('Playing Audio Book')
Now, let's run a loop for the number of pages in our pdf file. A page will get retrieved at each iteration.
for num in range(0,num_pages):
page = pdf_reader.getPage(num)
data= page.extractText()
play.say(data)
play.runAndWait()
Moving forward, let's extract the text from our page using extractText method on our page and store it into data.
Next, we will call say method on data and finally we can call runAndWait method at the end.
Run the python script and your Audiobook will play.
That's it. We are done. You can find the code at my GitHub Repository
If you have any queries or suggestions, feel free to reach out to me.
You can connect with me on Twitter.
You should definitely check out my other Blogs:
Resources:
See you in my next article, Take care!