Ryan and Debi & Toren

Converting EPUB to Mp3 on Linux

I read a lot. It’s part of my job. But I also have times when I have to be physically up and about and could listen to an audiobook (e.g., mowing the lawn). I typically listen to podcasts at those times, but I do have some e-books I’d like to listen to that don’t have an audiobook version (or I already bought the ebook but don’t want to also buy the audiobook). I found a fairly simple workflow in Linux that allows me to convert text to speech that I can then listen to on the go. Here’s how I did it (on Kubuntu 23.04).

First, you’ll need to install some software: calibre, pip, sox, and gTTs.

sudo apt-get install calibre pip

That will install calibre, which is amazing, robust software for managing ebooks, and pip, which is the Python package manager. Once you’ve got those two installed, then install the other two:

sudo pip install sox gTTs

That will install sox, which is a command line tool for editing audio files, and gTTs, which is Google’s Text-To-Speech service that will let you create an audio file from text.

Once you have everything installed, import your ebook into Calibre. Mine was in EPUB format. Then, click on the “Convert” option at the top of Calibre.

That will open up a new window that lets you choose the output format. Select “TXT” as you just want the text from the book.

Once you’ve selected your output format, select OK and Calibre will convert your ebook into a text file.

That will likely be stored in your Calibre folder. You’ll need to know where it is and what it is called for the next step.

Now, open a terminal. Here’s the code to convert the text file into an mp3:

gtts-cli -f [name of text file].txt --output [name of audio file].mp3

That line calls the gTTs program, tells it which text file you want it to convert to audio (the “-f” followed by the name of the text file), and the last part tells it what to name the resulting file (the “–output” followed by the name of the file). If you have a long book, this will take some time but it will generate an audio version of your book.

(I got a lot of the information I needed for this article from this website.)

Exit mobile version