Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Convert To Audio Book

A Python-based command-line tool that takes an EPUB or PDF document and converts it into a high-quality MP3 audiobook using native macOS text-to-speech capabilities.

Features

  • Multi-format Support: Extracts text flawlessly from both .epub (chapter-by-chapter) and .pdf (sentence-by-sentence) files.
  • 100% Offline & Fast: Utilizes the built-in macOS say command for high-quality, offline text-to-speech generation. No API keys or internet connection required.
  • Efficient Audio Merging: Automates the ffmpeg concat demuxer to losslessly and efficiently stitch hundreds of audio chunks into a single, seamless .mp3 file, without blowing up your system's memory.
  • Customizable Voices: Pick any installed macOS system voice (e.g., Alex, Samantha, Daniel) to read your books.

Prerequisites

  • macOS (Required for the native say TTS command).
  • Python 3.9+

(Note: ffmpeg is required to merge the audio files, but this script will automatically download a static binary into your virtual environment if one isn't natively installed via Homebrew!)

Installation

  1. Clone or download the repository.
  2. Create and activate a Python virtual environment:
    python3 -m venv venv
    source venv/bin/activate
  3. Install the required dependencies:
    pip install EbookLib==0.18 beautifulsoup4==4.12.3 PyMuPDF==1.23.21 tqdm==4.66.2 click==8.1.7

Usage

Simply run main.py against your document:

# Basic usage (defaults to the "Alex" voice)
python main.py my_book.epub --output my_audiobook.mp3

# Use a specific macOS voice (e.g., Samantha)
python main.py my_document.pdf -v Samantha --output my_audiobook.mp3

Options

  • input_file: The path to the .epub or .pdf file you want to convert.
  • --output / -o: Output audiobook file path (default: audiobook.mp3).
  • --voice / -v: The macOS system voice to use (default: Alex).

Architecture

  • extractor.py: Parses the files into clean, readable text chunks using ebooklib, beautifulsoup4, and PyMuPDF.
  • tts_engine.py: Converts the text chunks into audio files asynchronously using macOS say.
  • compiler.py: Merges the generated audio files into the final audiobook using ffmpeg.
  • main.py: The CLI application tying everything together with beautiful progress tracking via click and tqdm.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages