The Direct Link

Search Any Links, Share Direct Links

Development

Audiobook pdf to voice

By Cody, Published on 3 years ago, 692 Views
Tags : #python #pyaudio #pypdf2 #pyttsx3 #python_pdf_to_voice

Here with Python 12 lines code, you can be able to hear the PDF text as a voice output. The python code can read all the printable text from a PDF file/book. Installation To read a PDF file using Python, pip install pypdf2. To read text (Text to speech) pip install pyaudio pip install pyttsx3.

Read any audio book using 12 lines of python

PIP Packages: pip install pypdf2
pip install pyaudio
pip install pyttsx3

import pyttsx3
import PyPDF2
book = open('oop.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(book)
pages = pdfReader.numPages
speaker = pyttsx3.init()
for num in range(7, pages):
 page = pdfReader.getPage(num)
 text = page.extractText()
 speaker.say(text)
 speaker.runAndWait()

Save this code in main.py
Here oop.pdf is a sample pdf file to read the pdf text
Run python main.py

Go to Github Link →

Report Inappropriate content / Link not working ?