Metadata-Version: 2.3
Name: audiblez
Version: 0.2.0
Summary: Generate audiobooks from e-books (epub to wav/m4b)
Home-page: https://claudio.uk/posts/epub-to-audiobook.html
Author: Claudio Santini
Author-email: hireclaudio@gmail.com
Requires-Python: >=3.9,<3.13
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: attrs (==24.3.0)
Requires-Dist: audioread (==3.0.1)
Requires-Dist: babel (==2.16.0)
Requires-Dist: beautifulsoup4 (==4.12.3)
Requires-Dist: bibtexparser (==2.0.0b8)
Requires-Dist: bs4 (==0.0.2)
Requires-Dist: certifi (==2024.12.14)
Requires-Dist: cffi (==1.17.1)
Requires-Dist: charset-normalizer (==3.4.1)
Requires-Dist: clldutils (==3.24.0)
Requires-Dist: colorama (==0.4.6)
Requires-Dist: coloredlogs (==15.0.1)
Requires-Dist: colorlog (==6.9.0)
Requires-Dist: csvw (==3.5.1)
Requires-Dist: decorator (==5.1.1)
Requires-Dist: dlinfo (==1.2.1)
Requires-Dist: ebooklib (==0.18)
Requires-Dist: espeakng-loader (==0.2.1)
Requires-Dist: flatbuffers (==24.12.23)
Requires-Dist: humanfriendly (==10.0)
Requires-Dist: idna (==3.10)
Requires-Dist: isodate (==0.7.2)
Requires-Dist: joblib (==1.4.2)
Requires-Dist: jsonschema (==4.23.0)
Requires-Dist: jsonschema-specifications (==2024.10.1)
Requires-Dist: kokoro-onnx (==0.2.6)
Requires-Dist: language-tags (==1.2.0)
Requires-Dist: lazy-loader (==0.4)
Requires-Dist: librosa (==0.10.2.post1)
Requires-Dist: llvmlite (==0.43.0)
Requires-Dist: lxml (==5.3.0)
Requires-Dist: markdown (==3.7)
Requires-Dist: markupsafe (==3.0.2)
Requires-Dist: mpmath (==1.3.0)
Requires-Dist: msgpack (==1.1.0)
Requires-Dist: numba (==0.60.0)
Requires-Dist: numpy (==2.0.2)
Requires-Dist: onnxruntime (==1.20.1)
Requires-Dist: packaging (==24.2)
Requires-Dist: phonemizer-fork (==3.3.1)
Requires-Dist: pick (>=2.4.0,<3.0.0)
Requires-Dist: platformdirs (==4.3.6)
Requires-Dist: pooch (==1.8.2)
Requires-Dist: protobuf (==5.29.3)
Requires-Dist: pycparser (==2.22)
Requires-Dist: pydub (>=0.25.1,<0.26.0)
Requires-Dist: pylatexenc (==2.10)
Requires-Dist: pyparsing (==3.2.1)
Requires-Dist: python-dateutil (==2.9.0.post0)
Requires-Dist: rdflib (==7.1.2)
Requires-Dist: referencing (==0.35.1)
Requires-Dist: regex (==2024.11.6)
Requires-Dist: requests (==2.32.3)
Requires-Dist: rfc3986 (==1.5.0)
Requires-Dist: rpds-py (==0.22.3)
Requires-Dist: scikit-learn (==1.6.1)
Requires-Dist: scipy (==1.15.1)
Requires-Dist: segments (==2.2.1)
Requires-Dist: six (==1.17.0)
Requires-Dist: soundfile (==0.13.0)
Requires-Dist: soupsieve (==2.6)
Requires-Dist: soxr (==0.5.0.post1)
Requires-Dist: sympy (==1.13.3)
Requires-Dist: tabulate (==0.9.0)
Requires-Dist: threadpoolctl (==3.5.0)
Requires-Dist: typing-extensions (==4.12.2)
Requires-Dist: uritemplate (==4.1.1)
Requires-Dist: urllib3 (==2.3.0)
Project-URL: Documentation, https://github.com/santinic/audiblez
Project-URL: Issues, https://github.com/santinic/audiblez/issues
Project-URL: Repository, https://github.com/santinic/audiblez
Description-Content-Type: text/markdown

# Audiblez: Generate  audiobooks from e-books
[![Installing via pip and running](https://github.com/santinic/audiblez/actions/workflows/pip-install.yaml/badge.svg)](https://github.com/santinic/audiblez/actions/workflows/pip-install.yaml)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/audiblez)
![PyPI - Version](https://img.shields.io/pypi/v/audiblez)

Audiblez generates `.m4b` audiobooks from regular `.epub` e-books, 
using Kokoro's high-quality speech synthesis.

[Kokoro v0.19](https://huggingface.co/hexgrad/Kokoro-82M) is a recently published text-to-speech model with just 82M params and very natural sounding output.
It's released under Apache licence and it was trained on < 100 hours of audio.
It currently supports American, British English, French, Korean, Japanese and Mandarin, and a bunch of very good voices.

On my M2 MacBook Pro, **it takes about 2 hours to convert to mp3 the Selfish Gene by Richard Dawkins**, which is about 100,000 words (or 600,000 characters),
at a rate of about 80 characters per second.

## How to install and run

If you have Python 3 on your computer, you can install it with pip.
Be aware that it won't work with Python 3.13.
Then you also need to download a couple of additional files in the same folder, which are about ~360MB:

```bash
pip install audiblez
wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/kokoro-v0_19.onnx
wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/voices.json
```

Then, to convert an epub file into an audiobook, just run:

```bash
audiblez book.epub -l en-gb -v af_sky
```

It will first create a bunch of `book_chapter_1.wav`, `book_chapter_2.wav`, etc. files in the same directory,
and at the end it will produce a `book.m4b` file with the whole book you can listen with VLC or any
audiobook player.
It will only produce the `.m4b` file if you have `ffmpeg` installed on your machine.

## Supported Languages
Use `-l` option to specify the language, available language codes are:
🇺🇸 `en-us`, 🇬🇧 `en-gb`, 🇫🇷 `fr-fr`, 🇯🇵 `ja`, 🇰🇷 `kr` and 🇨🇳 `cmn`.

## Speed
By default the audio is generated using a normal speed, but you can make it up to twice slower or faster by specifying a speed argument between 0.5 to 2.0:

```bash
audiblez book.epub -l en-gb -v af_sky -s 1.5
```

## Supported Voices
Use `-v` option to specify the voice:
available voices are `af`, `af_bella`, `af_nicole`, `af_sarah`, `af_sky`, `am_adam`, `am_michael`, `bf_emma`, `bf_isabella`, `bm_george`, `bm_lewis`.
You can try them here: [https://huggingface.co/spaces/hexgrad/Kokoro-TTS](https://huggingface.co/spaces/hexgrad/Kokoro-TTS)


## How to run on GPU
By default audiblez runs on CPU. If you want to use a GPU for faster performance, install the GPU-enabled ONNX Runtime and specify a runtime provider with the `--providers` flag. By default, the CPU-enabled ONNX Runtime is installed. The GPU runtime must be installed manually.

```bash
pip install onnxruntime-gpu
```

To specify ONNX providers, such as using an NVIDIA GPU, use the `--providers` tag. For example:

```bash
audiblez book.epub -l en-gb -v af_sky --providers CUDAExecutionProvider
```

To see the list of available providers on your system, run the following:

```bash
audiblez --help
```

or

```bash
python -c "import onnxruntime as ort; print(ort.get_available_providers())"
```

This will display the ONNX providers that can be used, such as `CUDAExecutionProvider` for NVIDIA GPUs or `CPUExecutionProvider` for CPU-only execution.

You can specify a provider hierarchy by providing multiple hierarchies separated by spaces.

```bash
audiblez book.epub -l en-gb -v af_sky --providers CUDAExecutionProvider CPUExecutionProvider
```

## Author
by [Claudio Santini](https://claudio.uk) in 2025, distributed under MIT licence.

Related article: [Convert E-books into audiobooks with Kokoro](https://claudio.uk/posts/epub-to-audiobook.html)

