Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

cmulay/PDFtoAudio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Python-Automation-Script

This Python Automation Script will read PDF's out loud.

Installation

Check whether you are running latest package manager pip

pip install --upgrade pip

Use the package manager to install pyttsx3.

pip install pyttsx3

Similarly install PyPDF2.

pip install PyPDF2

Usage

Import installed libraries

import pyttsx3 # Python Text to Speech Version 3
import PyPDF2 # Python PDF Reader/Writer 2

Copy & Paste your desired PDF in project folder.

Open the book you want to listen

book = open('pdf_name.pdf', 'rb') # Opens pdf in book (replace pdf_name.pdf with you pdf name)

Pre-work such as reading total number of pages from the book

pdfReader = PyPDF2.PdfFileReader(book) # Reads book
pages = pdfReader.numPages # Calculates total number of pages from book
print(pages) # prints total number of pages  

Initialize Python Text to Speech

bot = pyttsx3.init()
for num in range(0, pages): # from first page (0) to calculated last page
    page = pdfReader.getPage(0)
    # to skip index and pdf clutter replace 0 with your desired page number - 1
    text = page.extractText()
    bot.say(text)
    bot.runAndWait()

License

GNU GENERAL PUBLIC LICENSE

About

Handy Python Automation Script for PDF's to read out loud like audio books.

Topics

Resources

License

Stars

Watchers

Forks

Languages