Make your own audiobook in just 5 lines of code

Ambuj Pawar
1 min readDec 29, 2021

In the ongoing lockdown, I have gotten into the habit of listening to podcasts/audiobooks during my evening walks. I also love to read articles on medium, news to keep me updated on the world as well during these tumultuous times. But I was not getting the motivation to read those every day. This sparked an idea in me whether I can convert these articles to audiobooks to listen to during my evening walks.

One of the most popular libraries for text-to-speech conversion is gTTS(Google text-to-speech). You can easily install it by simply typing this on the terminal:

pip install gTTS

To convert an article of your choice to speech. Firstly, copy your article to notepad or any text editor and save it in .txt format or any other format of your choice. Then simply pass the path to the .txt file to the code below and the path where you want your audio file to be present.

Your audio file of the article will be present in the location you provided. Have fun listening to your articles!!

The code for this project is present over here. For other projects of mine, please check out my Github.

--

--

Ambuj Pawar

Computer vision scientist in the Netherlands. Teaching computers to become a bit smarter every day.