Digitalise Agency

pdf-to-audiobook

PDF to Audiobook

A small desktop program that turns a PDF, a long report or a book chapter, into an mp3 you can listen to on a walk or a commute. You pick the files, it reads the text off every page and saves the spoken version next to the original. It needs an internet connection: the voice comes from Google's speech service, not from your own machine.

Solo

Solo work by our founder, Salman Adnan.

Pages to Waves: a book gives up its pages, the words are lifted off them, and they leave as a sound wave. That is the whole program: a PDF goes in, a spoken mp3 comes out. Live and interactive: drag it to orbit, scroll or pinch to zoom. Open full screen
The real PDF to Audiobook desktop tool, showing its main window.
Live screenshot of the actual Tkinter app.
2files: converter.py + main.py
0API keys required (gTTS)
VerifiedCLI run produced a playable mp3

Overview

A small desktop tool that takes one or more PDFs, pulls out the text, and saves each one as an mp3 you can listen to instead of read. Text extraction runs through PyPDF2 and speech synthesis through gTTS, which calls Google Translate's public TTS endpoint over HTTPS, so it needs an internet connection and has no offline fallback.

Reading long PDFs on a screen gets tiring, so this tool turns a PDF into audio instead of a subscription reader or web app. Pick one or more PDFs through a native Tkinter file dialog (or add more to an existing selection), extract the text from every page, and get back an mp3 saved next to the source PDF inside a tts_pdf folder.

Key features

  • Native file dialog to pick one or more PDFs, with an "Add Files" option to extend an existing selection.
  • Extracts text from every page of each PDF with PyPDF2 and joins it into one document.
  • Converts the extracted text to speech with gTTS and saves it as an mp3 in a tts_pdf folder next to the source file.
  • Also runs from the command line with no GUI, for scripting or headless testing.
  • Conversion logic (converter.py) has no GUI dependency, so it can be tested without opening a window.

Verification

No sample input shipped with the project, so the CLI path was verified end to end against a generated one-line test PDF: python3 converter.py path/to/file.pdf produced a real playable mp3, confirmed with file reporting valid MPEG audio. The GUI itself relies on the same conversion functions, which is exactly why they were split out and given their own CLI entry point in the first place.

Tech stack

  • Python 3
  • tkinter
  • PyPDF2
  • gTTS
  • argparse

A challenge worth noting

PyPDF2 returns None instead of an empty string for pages it can't extract text from (common for scanned or image-only pages), and concatenating None with a string raises a TypeError. converter.py falls back to an empty string per page (page.extract_text() or "") so one bad page doesn't crash a whole batch, and raises a clear ValueError if a PDF has no extractable text at all instead of silently writing an empty audio file. Path handling was also rewritten from manual split('/') calls to os.path functions, since the original only worked on POSIX paths and broke on Windows.

Book a call

Let's talk about what you're building.

Pick a slot below. No forms, no back-and-forth emails.