Skip to main content

Create your own Audiobook using python| Ebook| PDF reader using python| python for beginner

 Hello reader's

In this post you are going to see that "How you can create your own audiobook or Ebook" or simply a pdf reader using python. For doing this you must have basic knowledge of python. 




First of all install python on your laptop or desktop or what ever machine you are using, to download python click here.

If you don't know how to install python then you can checkout my other post's in which i have explained how to install python and any IDE which supports python. After the successful installation of python install a IDE which supports python or you can use Python's IDE too. 

There is also a different IDE's which support's python, like - VS Code, Pycharm are well known for python development. 

After the successful installation of python and it's supportive IDE lets get into the code , now you have to install some modules to run the code, Modules are nothing but some files with the “. py” extension containing Python code that can be imported inside another Python Program. In simple terms, we can consider a module to be the same as a code library or a file that contains a set of functions that you want to include in your application. 

now lets install the modules, Open your command prompt and type "pip install pyttsx3" pyttsx3 is a is a text-to-speech conversion library in Python. Unlike alternative libraries, it works offline, and is compatible with both Python 2 and 3. 



installing pyttsx3 using pip in cmd


As you can see in the above picture, i have already installed that's why it is showing me that requirement already satisfied but in your case it will install. 

After the successful installation of pyttsx3 , you have to install one more module named PyPDF2. To install PyPDF2 type "pip install pypdf2" in command prompt. 



installing Pypdf2 using pip in cmd


After the successful installation of code , let's start with code , Open your favourite IDE and type code .

First import all the two modules which you have installed using pip command. so type "import pyttsx3 import PyPDF2"  this lines going to import import the modules. 
now type , "book = open('Filename.pdf', 'rb')"  This line going to fetch the pdf file which you have stored at some location in storage. 
"pdfReader = PyPDF2.PdfFileReader(book)" This line is going to initialize the PyPDF2 module. 
If you want to know that how many pages are there in that perticular file the type "pages = pdfReader.numPages" This line of code is going to tell you that how many number of pages are there in that pdf file. 
Now you have initialize the speaker to speak up or to read the pdf , for initializing the speaker type "speaker = pyttsx3.init()" . 

"for num in range(1, pages):
    page = pdfReader.getPage(num)"  This two lines of code is going tell you that there are how many number of pages are there in pdf. 

"text = page.extractText()
    speaker.say(text)"
 This two lines of code is going to extract text from pdf, mainly these two lines of code are going to read out the pdf. 

   " speaker.runAndWait()"  This function will make the speech audible in the system, if you don't write this command then the speech will not be audible to you.







Code :- 
import pyttsx3
import PyPDF2
book = open('The Django Book ( PDFDrive ).pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(book)

pages = pdfReader.numPages
speaker = pyttsx3.init()
for num in range(1, pages):
    page = pdfReader.getPage(num)
    text = page.extractText()
    speaker.say(text)
    speaker.runAndWait()

Comments

Post a Comment

Thank you for sharing this.

You’re helping us become better. Want to stay in the loop? Subscribe to our YouTube channel.

Popular posts from this blog

S.Y.I.T Sem 3 Python Practical | Python| Python practical 1a| Print name and age +100 | python for beginner

 Hello reader's , This blog is for those students who are studying in second year of information technology. This blog is for practical of python  subject which is in sem 3. In this blog you are going to see that how you can ask user to enter their name and age. Print out a message addressed to them that tells them the year that they will turn 100 year old. For performing this practical you must have install python on your laptop or pc. to download python  - https://www.python.org/downloads/  python website  go to the link and download python and you need a IDE which supports python,  i am using VS Code, you can use python IDE too.  vs code screen After the successful installation open ide and type the code or simply copy the code from given link in below and run it to see the output. code -  name = input("Enter your name: ") age = int(input("Enter your age: ")) year = str((2021 - age)+100) print(name + "will be 100 years old in the year"+year)

Simple calculator using python| Python | Calculator | python for beginner

 Hello reader's, Today you are going to see that how can you develop your own calculator using python . simple calculator using python To perform this activity you must have installed python on your system.   To install python perform the following steps :- 1) Go to - https://www.python.org/downloads/  2) click "Download" . 3) Download the any latest python version from the given website . 4) When download complete just open your file explorer and double click on downloaded python file and install the python in which directory you want.  5) After the successful installation just double click on python icon on desktop to open python IDE.  python logo  After the successful installation of python you need a IDE which support python. I am using VS code(Visual studio code), you can use pycharm or python ide too. how to install VS Code? To install VS code(Visual Studio code) follow these steps :-  1) Go to - https://code.visualstudio.com/download  2) S...

Print calendar using python | Python| Calendar using Python |python for beginner

Hello readers, Today, we are going to see that how can we print the calendar using python.   Print calendar using python  In this blog you are going to see that how can you print calendar using python programming language. To perform this activity you must know the basics of python because we are going to use python programming language.   To perform this activity you must have to install python on your laptop or desktop. If you don't know that how to install python then follow these steps.    To install python perform the following steps :- 1) Go to - https://www.python.org/downloads/  2) click "Download" . 3) Download the any latest python version from the given website . 4) When download complete just open your file explorer and double click on downloaded python file and install the python in which directory you want.  5) After the successful installation just double click on python icon on desktop to open python IDE.  python logo  Af...