Projects

PDF to Audiobook

published 2021-09-20

Overview

Audiobooks are great. I find it's often easier to listen than read, and they make it so you can consume whatever text you need while taking a walk, doing laundry, or doing pretty much anything else that doesn't require too much focus.

Another thing I love about audiobooks is that you can adjust the playback speed and get through text super fast. This means that if, hypothetically, you had to read a book or something for a school assignment and you just... didn't do that... you could still listen to the audiobook at 4x speed and get enough of the content that you could pass a test or something.

Unfortunately, audiobooks often cost money, and sometimes whatever you're reading doesn't have one out there. Company memos and scientific articles, for example, very rarely have them. I think that's lame, so I wrote a program to fix that.

I'd just like to note that real audiobooks take time and effort to make, and if you're able to I would say it is 120% better to support those who make them than to use this program.

If you're using this for books, it's also definitely worth knowing that actual books take gargantuan amounts of time and effort to write and publish, so while you can probably find (often illegal) PDFs of them on the internet with some creative googling, it's definitely better to not use those and instead support the author(s) of whatever you're reading.

You can find the repo for this project [here].(https://github.com/WheatleyTheCore/PDF_to_Audio)

What it does

This program takes in a PDF and spits out an audio file. You need internet connection for it to work, since it uses a third-party API for the text-to-speech.

It works with any number of PDF pages. If your PDF is ridiculously long it might eat up some memory (which is something I plan to fix at some point), but it will still run.

How to use it

The syntax is pretty simple, basically:

python pdftoaudio.py <pdfFile.pdf> <outputFileName.mp3>

Make sure you have the Python installed, along with the packages gTTS and PyPDF2 (which can be installed through pip).

I wish you the best of luck on that test you have in a day or two.