Convert PDF File Text to Audio Speech using Python (original) (raw)

Last Updated : 28 Nov, 2024

Let us see how to read a PDF that is converting a textual PDF file into audio.

Packages Used:

Both these modules need to be installed

pip install pyttsx3
pip install PyPDF2

You also need to know about the **open() function which will help us to open the PDF in read mode. Knowledge about the OOPS Concept is also recommended.

**Approach:

Now here the code for it

Python `

importing the modules

import PyPDF2 import pyttsx3

path of the PDF file

path = open('file.pdf', 'rb')

creating a PdfFileReader object

pdfReader = PyPDF2.PdfFileReader(path)

the page with which you want to start

this will read the page of 25th page.

from_page = pdfReader.getPage(24)

extracting the text from the PDF

text = from_page.extractText()

reading the text

speak = pyttsx3.init() speak.say(text) speak.runAndWait()

`

**Output:

Similar Reads

Projects for Beginners
























Projects for Intermediate


















Web Scraping












Automating boring Stuff Using Python

















Tkinter Projects



































Turtle Projects












OpenCV Projects

































Python Django Projects














Python Text to Speech and Vice-Versa