audiblez/README.md

157 lines
8.3 KiB
Markdown
Raw Permalink Normal View History

2025-02-09 19:21:27 +01:00
# Audiblez: Generate audiobooks from e-books
2025-01-29 20:24:01 +01:00
2025-01-15 00:09:27 +01:00
[![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)
2025-01-29 20:24:01 +01:00
[![Git clone and run](https://github.com/santinic/audiblez/actions/workflows/git-clone-and-run.yml/badge.svg)](https://github.com/santinic/audiblez/actions/workflows/git-clone-and-run.yml)
2025-01-15 09:40:15 +01:00
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/audiblez)
![PyPI - Version](https://img.shields.io/pypi/v/audiblez)
2025-01-14 16:30:25 +01:00
2025-02-09 18:32:55 +01:00
### v4 Now with Graphical interface, CUDA support, and many languages!
![Audiblez GUI on MacOSX](./imgs/mac.png)
2025-01-29 20:24:01 +01:00
Audiblez generates `.m4b` audiobooks from regular `.epub` e-books,
2025-01-14 22:57:31 +01:00
using Kokoro's high-quality speech synthesis.
2025-01-14 16:30:25 +01:00
2025-01-29 20:24:01 +01:00
[Kokoro-82M](https://huggingface.co/hexgrad/Kokoro-82M) is a recently published text-to-speech model with just 82M params and very natural sounding output.
2025-01-14 22:57:31 +01:00
It's released under Apache licence and it was trained on < 100 hours of audio.
2025-02-01 15:15:27 +01:00
It currently supports these languages: 🇺🇸 🇬🇧 🇪🇸 🇫🇷 🇮🇳 🇮🇹 🇯🇵 🇧🇷 🇨🇳
2025-01-29 20:24:01 +01:00
2025-02-07 01:20:20 +09:00
On a Google Colab's T4 GPU via Cuda, **it takes about 5 minutes to convert "Animal's Farm" by Orwell** (which is about 160,000 characters) to audiobook, at a rate of about 600 characters per second.
2025-01-14 16:30:25 +01:00
2025-01-29 20:24:01 +01:00
On my M2 MacBook Pro, on CPU, it takes about 1 hour, at a rate of about 60 characters per second.
2025-01-14 16:30:25 +01:00
2025-02-10 14:21:39 +01:00
2025-02-11 09:49:47 +01:00
## How to install the Command Line tool
2025-01-14 16:30:25 +01:00
2025-01-15 09:49:08 +01:00
If you have Python 3 on your computer, you can install it with pip.
2025-01-31 20:07:39 +01:00
You also need `espeak-ng` and `ffmpeg` installed on your machine:
2025-01-14 16:30:25 +01:00
2025-01-14 22:57:31 +01:00
```bash
2025-02-11 09:33:48 +01:00
sudo apt install ffmpeg espeak-ng # on Ubuntu/Debian 🐧
2025-01-14 22:57:31 +01:00
pip install audiblez
2025-02-09 19:55:21 +01:00
```
2025-01-31 20:07:39 +01:00
2025-02-10 14:21:39 +01:00
```bash
2025-02-09 22:09:51 +01:00
brew install ffmpeg espeak-ng # on Mac 🍏
2025-02-09 19:55:21 +01:00
pip install audiblez
2025-01-14 16:30:25 +01:00
```
2025-02-11 09:33:48 +01:00
Then you can convert an .epub directly with:
2025-01-14 16:30:25 +01:00
2025-02-10 14:21:39 +01:00
```
2025-01-29 20:24:01 +01:00
audiblez book.epub -v af_sky
2025-01-14 16:30:25 +01:00
```
2025-01-14 22:57:31 +01:00
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.
2025-01-14 22:57:31 +01:00
It will only produce the `.m4b` file if you have `ffmpeg` installed on your machine.
2025-02-11 09:33:48 +01:00
## How to run the GUI
2025-02-11 09:36:03 +01:00
The GUI is a simple graphical interface to use audiblez.
You need some extra dependencies to run the GUI:
2025-02-11 09:33:48 +01:00
```
sudo apt install ffmpeg espeak-ng
2025-02-11 09:34:48 +01:00
sudo apt install libgtk-3-dev # just for Ubuntu/Debian 🐧, Windows/Mac don't need this
2025-02-11 09:33:48 +01:00
pip install audiblez pillow wxpython
```
Then you can run the GUI with:
```
audiblez-ui
```
2025-02-12 20:35:39 +01:00
## How to run on Windows
After many trials, on Windows we recommend to install audiblez in a Python venv:
1. Open a Windows terminal
2. Create anew folder: `mkdir audiblez`
3. Enter the folder: `cd audiblez`
4. Create a venv: `python -m venv venv`
5. Activate the venv: `.\venv\Scripts\Activate.ps1`
6. Install the dependencies: `pip install audiblez pillow wxpython`
7. Now you can run `audiblez` or `audiblez-ui`
8. For Cuda support, you need to install Pytorch accordingly: https://pytorch.org/get-started/locally/
2025-02-11 09:33:48 +01:00
2025-01-17 09:32:27 +01:00
## Speed
2025-01-29 20:24:01 +01:00
2025-01-17 09:32:27 +01:00
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:
2025-02-10 14:21:39 +01:00
```
2025-01-29 20:24:01 +01:00
audiblez book.epub -v af_sky -s 1.5
2025-01-17 09:32:27 +01:00
```
## Supported Voices
2025-02-09 19:21:27 +01:00
Use `-v` option to specify the voice to use. Available voices are listed here.
2025-02-01 13:04:38 +01:00
The first letter is the language code and the second is the gender of the speaker e.g. `im_nicola` is an italian male voice.
2025-02-11 09:52:26 +01:00
[For hearing samples of Kokoro-82M voices, go here](https://claudio.uk/posts/audiblez-v4.html)
2025-02-10 14:21:39 +01:00
| Language | Voices |
|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 🇺🇸 American English | `af_alloy`, `af_aoede`, `af_bella`, `af_heart`, `af_jessica`, `af_kore`, `af_nicole`, `af_nova`, `af_river`, `af_sarah`, `af_sky`, `am_adam`, `am_echo`, `am_eric`, `am_fenrir`, `am_liam`, `am_michael`, `am_onyx`, `am_puck`, `am_santa` |
| 🇬🇧 British English | `bf_alice`, `bf_emma`, `bf_isabella`, `bf_lily`, `bm_daniel`, `bm_fable`, `bm_george`, `bm_lewis` |
| 🇪🇸 Spanish | `ef_dora`, `em_alex`, `em_santa` |
| 🇫🇷 French | `ff_siwis` |
| 🇮🇳 Hindi | `hf_alpha`, `hf_beta`, `hm_omega`, `hm_psi` |
| 🇮🇹 Italian | `if_sara`, `im_nicola` |
| 🇯🇵 Japanese | `jf_alpha`, `jf_gongitsune`, `jf_nezumi`, `jf_tebukuro`, `jm_kumo` |
| 🇧🇷 Brazilian Portuguese | `pf_dora`, `pm_alex`, `pm_santa` |
| 🇨🇳 Mandarin Chinese | `zf_xiaobei`, `zf_xiaoni`, `zf_xiaoxiao`, `zf_xiaoyi`, `zm_yunjian`, `zm_yunxi`, `zm_yunxia`, `zm_yunyang` |
For more detaila about voice quality, check this document: [Kokoro-82M voices](https://huggingface.co/hexgrad/Kokoro-82M/blob/main/VOICES.md)
2025-01-29 20:24:01 +01:00
## How to run on GPU
2025-02-01 15:16:15 +01:00
By default, audiblez runs on CPU. If you pass the option `--cuda` it will try to use the Cuda device via Torch.
2025-01-29 20:24:01 +01:00
Check out this example: [Audiblez running on a Google Colab Notebook with Cuda ](https://colab.research.google.com/drive/164PQLowogprWQpRjKk33e-8IORAvqXKI?usp=sharing]).
2025-01-30 09:24:21 +01:00
We don't currently support Apple Silicon, as there is not yet a Kokoro implementation in MLX. As soon as it will be available, we will support it.
2025-02-01 13:09:18 +01:00
## Manually pick chapters to convert
Sometimes you want to manually select which chapters/sections in the e-book to read out loud.
2025-02-09 19:55:21 +01:00
To do so, you can use `--pick` to interactively choose the chapters to convert (without running the GUI).
2025-02-12 20:35:39 +01:00
2025-02-09 19:55:21 +01:00
## Help page
2025-02-10 14:21:39 +01:00
2025-02-09 19:55:21 +01:00
For all the options available, you can check the help page `audiblez --help`:
2025-02-10 11:35:38 +01:00
```
2025-02-09 19:55:21 +01:00
usage: audiblez [-h] [-v VOICE] [-p] [-s SPEED] [-c] [-o FOLDER] epub_file_path
positional arguments:
epub_file_path Path to the epub file
options:
-h, --help show this help message and exit
-v VOICE, --voice VOICE
Choose narrating voice: a, b, e, f, h, i, j, p, z
-p, --pick Interactively select which chapters to read in the audiobook
-s SPEED, --speed SPEED
Set speed from 0.5 to 2.0
-c, --cuda Use GPU via Cuda in Torch if available
-o FOLDER, --output FOLDER
Output folder for the audiobook and temporary files
example:
audiblez book.epub -l en-us -v af_sky
to use the GUI, run:
audiblez-ui
```
2025-02-01 13:09:18 +01:00
2025-01-15 00:49:20 +01:00
## Author
2025-01-29 20:24:01 +01:00
2025-01-15 00:49:20 +01:00
by [Claudio Santini](https://claudio.uk) in 2025, distributed under MIT licence.
2025-02-11 09:52:26 +01:00
Related Article: [Audiblez v4: Generate Audiobooks from E-books](https://claudio.uk/posts/audiblez-v4.html)