Skip to content

Commit

Permalink
Python script - Turn PDFs into Audiobooks
Browse files Browse the repository at this point in the history
A minimalistic python script to turn any PDF document into an audio book.

Dependencies:
1. PyPDF2  - https://github.com/mstamy2/PyPDF2 
2. pyttsx3    - https://github.com/nateshmbhat/pyttsx3

Usage: 
1. Place the PDF in same drectory as the script.
2. Execute the script: **python audiobook_gen.py** and enter the filename ( with.pdf/.PDF extension)
3. Enjoy your audiobook :)
  • Loading branch information
prateekralhan authored Oct 1, 2020
1 parent 41109b6 commit ae1d685
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Turn your PDFs into audio books/audiobook_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import PyPDF2
import pyttsx3

book = open(input('Enter the book name: '), 'rb')
pg_no = int(input("Enter the page number from which you want the system to start reading text: "))

pdf_Reader = PyPDF2.PdfFileReader(book)
pages = pdf_Reader.numPages

speaker = pyttsx3.init()

for num in range((pg_no-1), pages):
page = pdf_Reader.getPage(num)
text = page.extractText()
speaker.say(text)
speaker.runAndWait()

0 comments on commit ae1d685

Please sign in to comment.