Skip to main content

Generate audiobooks (mp3 files per chapter) from ebooks (currently only supports the epub format).

Project description

audiobook-generator - Generate audiobooks (epub) from ebooks (one mp3 per chapter)

Flow

graph TD;
    A[Input file] --> B["Convert to text and chapterize (Optionally extract out the cover image)"];
    B --> C[Transform to audio files];

Usage

Prerequisites

  • Python 3.10+ (This program was tested on 3.12)
  • (Optional) Install espeak-ng (On Debian/Ubuntu, run apt install -y espeak-ng)
  • (Development only) uv

For End Users

  • You DON'T need to clone this repository, but simply install it via pip (Virtual environment highly recommended, if you use pipx instead, virtual environments are automatically created for you.)
    • pip install audiobook-generator
  • Convert your epub file to audiobooks via the command
    • abg <epub path> <audio output directory>
  • If you want to see all the command line switches, just run abg -h

For Development

  • This program uses uv for dependency management and execution in development, install it first if you haven't done so.
  • To run the program from its source:
    • Clone this repository and cd inside.
    • (Do it ONCE only at the first time) Run uv sync to create the virtual environment in the .env directory and download all the dependencies.
    • Then run the following command
      • uv run -m audiobook_generator.main ...

CPU or GPU?

The selection to run the model on CPU or GPU is automatic, meaning:

  • On Windows/WSL/Linux, If you have Nvidia graphic card with the driver properly installed, the model will be loaded to GPU (cuda) and executed, otherwise, the CPU is used (which is slower compared to GPU)
  • On Mac, you need to set the environment variable PYTORCH_ENABLE_MPS_FALLBACK=1 for it to run on GPU (because at the time of writing, the MPS support in PyTorchis is not complete and it won't work without the CPU fallback), otherwise it will run on CPU.

Tip

You can use the following epub for testing: https://github.com/daisy/epub-accessibility-tests/releases/download/fundamental-2.0/Fundamental-Accessibility-Tests-Basic-Functionality-v2.0.0.epub

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audiobook_generator-1.0.4.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

audiobook_generator-1.0.4-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file audiobook_generator-1.0.4.tar.gz.

File metadata

  • Download URL: audiobook_generator-1.0.4.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.1

File hashes

Hashes for audiobook_generator-1.0.4.tar.gz
Algorithm Hash digest
SHA256 19ae98327c73c77dcd49f33cac11160ae638d682cfde42ad690808a9d86a1bd5
MD5 83c03f8c8ee1ad6655495d34f37734b9
BLAKE2b-256 22995f2da003887f21fb7575a0f145b16f1c29e6cc4cf32803aa327b4e63884f

See more details on using hashes here.

File details

Details for the file audiobook_generator-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for audiobook_generator-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 457e33c14bd30e5cce2931fb8c7e17eabc1a98c60ec73fa231eee139c4758702
MD5 2a1c455b22e559c733b1d710daab8ee4
BLAKE2b-256 6e03b721826fa638fa3eab737a47d31c97245d1d53140b2b93c34bd38cd813f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page