ebook2audiobook README

The project's README from github.com/DrewThomasson/ebook2audiobook. As one markdown file: README.md.

📚 ebook2audiobook (E2A)

DrewThomasson%2Febook2audiobook | Trendshift

CPU/GPU Converter from E-Book to audiobook with chapters and metadata
using advanced TTS engines and much more.
Supports voice cloning and 1696 languages!

[!IMPORTANT] This tool is intended for use with non-DRM, legally acquired eBooks only.
The authors are not responsible for any misuse of this software or any resulting legal consequences.
Use this tool responsibly and in accordance with all applicable laws.

Discord

Thanks to support ebook2audiobook developers!

Ko-Fi JOB

Run locally

Quick Start Docker Build Download

Platform Docker Pull Count

Run Remotely

Hugging Face Free Google Colab Kaggle

GUI Interface

demo_web_gui

Click to see images of Web GUI GUI Screen 1 GUI Screen 2 GUI Screen 3

Demos

New Default Voice Demo

https://github.com/user-attachments/assets/750035dc-e355-46f1-9286-05c1d9e88cea

More Demos

ASMR Voice

https://github.com/user-attachments/assets/68eee9a1-6f71-4903-aacd-47397e47e422

Rainy Day Voice

https://github.com/user-attachments/assets/d25034d9-c77f-43a9-8f14-0d167172b080

Scarlett Voice

https://github.com/user-attachments/assets/b12009ee-ec0d-45ce-a1ef-b3a52b9f8693

David Attenborough Voice

https://github.com/user-attachments/assets/81c4baad-117e-4db5-ac86-efc2b7fea921

Example

Example

README.md

Table of Contents

Features

Hardware Requirements

* Modern TTS engines are very slow on CPU, so use lower quality TTS like YourTTS, Tacotron2 etc..

Supported Languages

+1696 languages here

Supported eBook Formats

Output and process Formats

SML tags available

Check our other repo dedicated to add SML automatically in your ebook -> E2A-SML

[!IMPORTANT] Before to post an install or bug issue search carefully to the opened and closed issues TAB
to be sure your issue does not exist already.

[!NOTE] EPUB format lacks any standard structure like what is a chapter, paragraph, preface etc.
So you should first remove manually any text you don't want to be converted in audio.

Instructions

  1. Clone repo

    git clone https://github.com/DrewThomasson/ebook2audiobook.git
    cd ebook2audiobook
    
  2. Install / Run ebook2audiobook:

    • Linux/MacOS

      ./ebook2audiobook.command
      

      Note for MacOS users: homebrew is installed to install missing programs.

    • Mac Launcher
      Double click Mac Ebook2Audiobook Launcher.command

    • Windows

      ebook2audiobook.cmd
      

      or Double click ebook2audiobook.cmd

      Note for Windows users: scoop is installed to install missing programs without administrator privileges.

  3. Open the Web App: Click the URL provided in the terminal to access the web app and convert eBooks. http://localhost:7860/

  4. For Public Link: ./ebook2audiobook.command --share (Linux/MacOS) ebook2audiobook.cmd --share (Windows) python app.py --share (all OS, only once installed and with the python of its python_env folder)

[!IMPORTANT] If the script is stopped and run again, you need to refresh your gradio GUI interface
to let the web page reconnect to the new connection socket.

Install with pip / pipx

Another way to install and launch ebook2audiobook, without cloning the repo: pip installs the ebook2audiobook command
(all OS, any python 3.8+). The cloned repo with its launchers above keeps working the same way.

  1. Install the command from PyPI

    pipx install ebook2audiobook
    

    or with uv

    uv tool install ebook2audiobook
    

    or with pip

    pip install ebook2audiobook
    

    For the latest code not released yet, use git+https://github.com/DrewThomasson/ebook2audiobook.git in place of ebook2audiobook.

  2. Install / Run ebook2audiobook, with the same options as the launchers:

    ebook2audiobook
    
    ebook2audiobook --headless --ebook <path_to_ebook_file> --voice <path_to_voice_file> --language <language_code>
    

    If the command is not found (pip's scripts folder is not in your PATH): python -m ebook2audiobook

Basic Usage

Example of Custom Model Zip Upload

(must be a .zip file containing the mandatory model files. Example for XTTSv2: config.json, model.pth, vocab.json and ref.wav)

For Detailed Guide with list of all Parameters to use

usage: app.py [-h] [--session SESSION] [--share] [--headless] [--ebook EBOOK] [--ebooks_dir EBOOKS_DIR]
              [--language LANGUAGE] [--voice VOICE] [--voice_map VOICE_MAP] [--device {CPU,CUDA,MPS,ROCM,XPU,JETSON}]
              [--tts_engine {XTTS,BARK,VITS,FAIRSEQ,TACOTRON,YOURTTS,xtts,bark,vits,fairseq,tacotron,yourtts}]
              [--custom_model CUSTOM_MODEL] [--fine_tuned FINE_TUNED] [--output_format OUTPUT_FORMAT]
              [--output_channel OUTPUT_CHANNEL] [--temperature TEMPERATURE] [--length_penalty LENGTH_PENALTY]
              [--num_beams NUM_BEAMS] [--repetition_penalty REPETITION_PENALTY] [--top_k TOP_K] [--top_p TOP_P]
              [--speed SPEED] [--enable_text_splitting] [--text_temp TEXT_TEMP] [--waveform_temp WAVEFORM_TEMP]
              [--output_dir OUTPUT_DIR] [--version]

Convert eBooks to Audiobooks using a Text-to-Speech model. You can either launch the Gradio interface or run the script in headless mode for direct conversion.

options:
  -h, --help            show this help message and exit
  --session SESSION     Session to resume the conversion in case of interruption, crash,
                            or reuse of custom models and custom cloning voices.

**** The following option is for gradio/gui mode only:
  --share               (Optional) Enable a public shareable Gradio link.

**** The following options are for --headless mode only:
  --headless            Run the script in headless mode
  --ebook EBOOK         Path to the ebook file for conversion. Cannot be used when --ebooks_dir is present.
  --ebooks_dir EBOOKS_DIR
                        Relative or absolute path of the directory containing the files to convert.
                            Cannot be used when --ebook is present.
  --text TEXT           Raw text for conversion. Cannot be used when --ebook or --ebooks_dir is present.
  --language LANGUAGE   Language of the e-book. Default language is set
                            in ./lib/lang.py sed as default if not present. All compatible language codes are in ./lib/lang.py

optional parameters:
  --translate ISO3      (Optional) Translate ebook to a target language (ISO 639-3 code, e.g. eng, fra, deu) before TTS synthesis.
                            Uses argostranslate. The target language becomes the effective TTS language for the run.
                            A copy of the source ebook is made with the _<iso3> suffix so translated and non-translated
                            outputs stay isolated (independent process folder, audio chunks, and final file).
  --voice VOICE         (Optional) Path to the voice cloning file for TTS engine.
                            Uses the default voice if not present.
  --voice_map VOICE_MAP
                        (Optional, --ebooks_dir only) Path to a JSON file mapping ebook path -> voice path.
                            Each entry overrides --voice for that specific ebook. Missing/null entries fall back to --voice.
                            Keys may be absolute paths or basenames. Example:
                            {"book1.epub": "/voices/eng/adult/female/alice.wav", "/abs/path/book2.epub": null}
  --device {CPU,CUDA,MPS,ROCM,XPU,JETSON}
                        (Optional) Processor unit type for the conversion.
                            Default is set in ./lib/conf.py if not present. Fall back to CPU if CUDA or MPS is not available.
  --tts_engine {XTTS,BARK,VITS,FAIRSEQ,TACOTRON,YOURTTS,xtts,bark,vits,fairseq,tacotron,yourtts}
                        (Optional) Preferred TTS engine (available are: ['XTTS', 'BARK', 'VITS', 'FAIRSEQ', 'TACOTRON', 'YOURTTS', 'xtts', 'bark', 'vits', 'fairseq', 'tacotron', 'yourtts'].
                            Default depends on the selected language. The tts engine should be compatible with the chosen language
  --custom_model CUSTOM_MODEL
                        (Optional) Path to the custom model zip file cntaining mandatory model files.
                            Please refer to ./lib/models.py
  --fine_tuned FINE_TUNED
                        (Optional) Fine tuned model path. Default is builtin model.
  --output_format OUTPUT_FORMAT
                        (Optional) Output audio format. Default is m4b set in ./lib/conf.py
  --output_channel OUTPUT_CHANNEL
                        (Optional) Output audio channel. Default is mono set in ./lib/conf.py
  --temperature TEMPERATURE
                        (xtts only, optional) Temperature for the model.
                            Default to config.json model. Higher temperatures lead to more creative outputs.
  --length_penalty LENGTH_PENALTY
                        (xtts only, optional) A length penalty applied to the autoregressive decoder.
                            Default to config.json model. Not applied to custom models.
  --num_beams NUM_BEAMS
                        (xtts only, optional) Controls how many alternative sequences the model explores. Must be equal or greater than length penalty.
                            Default to config.json model.
  --repetition_penalty REPETITION_PENALTY
                        (xtts only, optional) A penalty that prevents the autoregressive decoder from repeating itself.
                            Default to config.json model.
  --top_k TOP_K         (xtts only, optional) Top-k sampling.
                            Lower values mean more likely outputs and increased audio generation speed.
                            Default to config.json model.
  --top_p TOP_P         (xtts only, optional) Top-p sampling.
                            Lower values mean more likely outputs and increased audio generation speed. Default to config.json model.
  --speed SPEED         (xtts only, optional) Speed factor for the speech generation.
                            Default to config.json model.
  --enable_text_splitting
                        (xtts only, optional) Enable TTS text splitting. This option is known to not be very efficient.
                            Default to config.json model.
  --text_temp TEXT_TEMP
                        (bark only, optional) Text Temperature for the model.
                            Default to config.json model.
  --waveform_temp WAVEFORM_TEMP
                        (bark only, optional) Waveform Temperature for the model.
                            Default to config.json model.
  --output_dir OUTPUT_DIR
                        (Optional) Path to the output directory. Default is set in ./lib/conf.py
  --abs_url ABS_URL     Audiobookshelf server URL (e.g. http://localhost:13378).
  --abs_api_token ABS_API_TOKEN
                        Audiobookshelf API token.
  --abs_library ABS_LIBRARY
                        Audiobookshelf library ID.
  --enable_interlude    Add MusicGen music before the first chapter, between chapters, and at the end of the audiobook. Settings are in ./lib/conf_interlude.py
  --version             Show the version of the script and exit

Example usage:
Windows:
    Gradio/GUI:
    ebook2audiobook.cmd
    Headless mode:
    ebook2audiobook.cmd --headless --ebook '/path/to/file' --language eng
Linux/Mac:
    Gradio/GUI:
    ./ebook2audiobook.command
    Headless mode:
    ./ebook2audiobook.command --headless --ebook '/path/to/file' --language eng
pip/pipx install (all OS, python 3.8+, no clone needed):
    pipx install ebook2audiobook
    (or: uv tool install ebook2audiobook, or: pip install ebook2audiobook)
    Gradio/GUI:
    ebook2audiobook
    Headless mode:
    ebook2audiobook --headless --ebook '/path/to/file' --language eng
    Docker build image:
    ebook2audiobook --script_mode build_docker [--docker_mode compose|podman]
    The first start installs e2a in ~/ebook2audiobook, or in the folder set in E2A_HOME,
    where ./ebook2audiobook.command (e2a.sh) or ebook2audiobook.cmd (e2a.cmd) also work.
    Run the docker commands printed after a build from that folder.
    Uninstall: ebook2audiobook --uninstall (it deletes the audiobooks folder too), then the command it prints.

SML tags available:
	[break] — silence (random range **0.3–0.6 sec.**)
	[pause] — silence (random range **1.0–1.6 sec.**)
	[pause:N] — fixed pause (**N sec.**)
	[voice:/path/to/voice/file]...[/voice] — switch voice from default or selected voice from GUI/CLI
	[emotion:sadness]...[/emotion] — Zonos2 and Zonos3 only: emotion for a passage (happiness, sadness, disgust, fear, surprise, anger, other, neutral; Zonos3 also calm, confused) or a mix like [emotion:sadness=0.7,neutral=0.3]; other engines ignore it

NOTE: in gradio/gui mode, to cancel a running conversion, just click on the [X] from the ebook upload component. TIP: if it needs some more pause, add '[pause:3]' for 3 sec. etc.

Docker

  1. Clone the Repository:
   git clone https://github.com/DrewThomasson/ebook2audiobook.git
   cd ebook2audiobook
  1. Build the container
    Windows:
        Docker:
            ebook2audiobook.cmd --script_mode build_docker
        Docker Compose:
            ebook2audiobook.cmd --script_mode build_docker --docker_mode compose
        Podman Compose:
            ebook2audiobook.cmd --script_mode build_docker --docker_mode podman
    Linux/Mac
        Docker:
            ./ebook2audiobook.command --script_mode build_docker
        Docker Compose
            ./ebook2audiobook.command --script_mode build_docker --docker_mode compose
        Podman Compose:
            ./ebook2audiobook.command --script_mode build_docker --docker_mode podman
  1. Run the Container:
Docker run image:
    Gradio/GUI:
        CPU:
          docker run --security-opt label=disable -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "e2a_venvs:/app/lib/classes/tts_engines/venvs" --rm -it -p 7860:7860 athomasson2/ebook2audiobook:cpu
        CUDA:
          docker run --security-opt label=disable -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "e2a_venvs:/app/lib/classes/tts_engines/venvs" --gpus all --rm -it -p 7860:7860 athomasson2/ebook2audiobook:cu[118/122/124/126 etc..]
        ROCM:
          docker run --security-opt label=disable -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "e2a_venvs:/app/lib/classes/tts_engines/venvs" --device=/dev/kfd --device=/dev/dri --rm -it -p 7860:7860 athomasson2/ebook2audiobook:rocm[6.0/6.1/6.4 etc..]
        XPU:
          docker run --security-opt label=disable -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "e2a_venvs:/app/lib/classes/tts_engines/venvs" --device=/dev/dri --rm -it -p 7860:7860 athomasson2/ebook2audiobook:xpu
        JETSON:
          docker run --security-opt label=disable -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "e2a_venvs:/app/lib/classes/tts_engines/venvs" --runtime nvidia --rm -it -p 7860:7860 athomasson2/ebook2audiobook:jetson[5/6/7 etc...]
    Headless mode:
        CPU:
          docker run --security-opt label=disable -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "e2a_venvs:/app/lib/classes/tts_engines/venvs" -v "/my/real/ebooks/folder/absolute/path:/app/another_ebook_folder" --rm -it -p 7860:7860 athomasson2/ebook2audiobook:cpu --headless --ebook "/app/another_ebook_folder/myfile.pdf" [--voice /app/my/voicepath/voice.mp3 etc..]
        CUDA:
          docker run --security-opt label=disable -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "e2a_venvs:/app/lib/classes/tts_engines/venvs" -v "/my/real/ebooks/folder/absolute/path:/app/another_ebook_folder" --gpus all --rm -it -p 7860:7860 athomasson2/ebook2audiobook:cu[118/122/124/126 etc..] --headless --ebook "/app/another_ebook_folder/myfile.pdf" [--voice /app/my/voicepath/voice.mp3 etc..]
        ROCM:
          docker run --security-opt label=disable -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "e2a_venvs:/app/lib/classes/tts_engines/venvs" -v "/my/real/ebooks/folder/absolute/path:/app/another_ebook_folder" --device=/dev/kfd --device=/dev/dri --rm -it -p 7860:7860 athomasson2/ebook2audiobook:rocm[6.0/6.1/6.4 etc.] --headless --ebook "/app/another_ebook_folder/myfile.pdf" [--voice /app/my/voicepath/voice.mp3 etc..]
        XPU:
          docker run --security-opt label=disable -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "e2a_venvs:/app/lib/classes/tts_engines/venvs" -v "/my/real/ebooks/folder/absolute/path:/app/another_ebook_folder" --device=/dev/dri --rm -it -p 7860:7860 athomasson2/ebook2audiobook:xpu --headless --ebook "/app/another_ebook_folder/myfile.pdf" [--voice /app/my/voicepath/voice.mp3 etc..]
        JETSON:
          docker run --security-opt label=disable -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "e2a_venvs:/app/lib/classes/tts_engines/venvs" -v "/my/real/ebooks/folder/absolute/path:/app/another_ebook_folder" --runtime nvidia --rm -it -p 7860:7860 athomasson2/ebook2audiobook:jetson[5/6/7 etc.] --headless --ebook "/app/another_ebook_folder/myfile.pdf" [--voice /app/my/voicepath/voice.mp3 etc..]
Docker Compose (i.e. cuda 12.8:
        Run Gradio GUI:
               DEVICE_TAG=cu128 docker compose --profile cuda up --no-log-prefix
        Run Headless mode:
               DEVICE_TAG=cu128 docker compose --profile cuda run --rm ebook2audiobook-cuda --headless --ebook "/app/ebooks/myfile.pdf" --voice /app/voices/eng/adult/female/some_voice.wav etc..
Podman Compose (i.e. cuda 12.8:
        Run Gradio GUI:
               DEVICE_TAG=cu128 podman-compose -f podman-compose.yml --profile cuda up
        Run Headless mode:
               DEVICE_TAG=cu128 podman-compose -f podman-compose.yml --profile cuda run --rm ebook2audiobook-cuda --headless --ebook "/app/ebooks/myfile.pdf" --voice /app/voices/eng/adult/female/some_voice.wav etc..

Tools

Standalone tools, run with e2a's own Python (python_env, created by the first launch of e2a).

Preload models for offline installs: tools/preload_models.py

Downloads every model e2a uses (TTS engines and their fine-tunes, voice conversion, stanza, pyannote, demucs, voice isolator, music interludes, argos-translate packages, tesseract data, jieba, and the voices) into one folder laid out exactly like ./models, i.e. a USB key. On the offline machine, copy that folder into e2a's ./models and the voices folder written beside it into e2a's ./voices. Every finished job is recorded in <models_dir>/.e2a_downloads.json: a rerun skips what is done and starts again what was cut (ctrl-c, crash, unplugged key) after removing its partial files.

usage: preload_models.py [-h] [--only ONLY] [--skip SKIP] [--languages LANGUAGES]
                         [--audiocpp_packages AUDIOCPP_PACKAGES] [--refresh] [--dry_run]
                         models_dir

Download every model e2a uses into one folder laid out exactly like ./models (i.e. a USB key for offline
installs).

positional arguments:
  models_dir            Target folder, i.e. /media/user/KEY/models or E:\models

options:
  -h, --help            show this help message and exit
  --only ONLY           Comma list of categories: common,xtts,bark,tortoise,vits,fairseq,glowtts,tacotron,yo
                        urtts,piper,zonos2,zonos3,audiocpp,audiocpp_server,gptsovits,f5tts,zipvoice,omnivoic
                        e,orpheus,sparktts,chattts,csm,kitten_tts,openvoice,melotts,phonon,stanza,pyannote,d
                        emucs,voice_isolator,interlude,argos,tessdata,jieba,voices
  --skip SKIP           Comma list of categories to leave out
  --languages LANGUAGES
                        Comma list of e2a ISO-639-3 codes (eng,fra,ita...): single-language models and fine-
                        tunes for these only, multilingual models only for engines speaking one of them
  --audiocpp_packages AUDIOCPP_PACKAGES
                        audiocpp_server category: auto (the packages this machine runs, GPU and CPU), all
                        (every platform, for a key used elsewhere), or a comma list of audiocpp_packages
                        keys from lib/conf_models.py
  --refresh             Run every job again, even those already marked done (files already there are still
                        not downloaded twice)
  --dry_run             List every download job with its state (done, interrupted, todo) and exit

Translate ebooks out of e2a: tools/translate_ebook.sh / tools/translate_ebook.cmd

Translates EPUB/AZW3 files, a whole folder (-r for its subfolders) or a list of paths (@list.txt) into translated ebooks, offline, with the Argos Translate calibre plugin shipped in tools/translate_ebook/argostranslate-calibre-plugin.zip. Independent of the audiobook conversion: it only writes ebooks. It needs calibre (already required by e2a) and runs on e2a's python_env and argos-translate packages: a language pair e2a already uses is not downloaded again, a missing one is downloaded on first use. The plugin is installed on first use into e2a's own calibre profile (./run), your calibre is left untouched. --to fra,ara,spa translates into several languages at once, one ebook per language, and --to all into every language the source reaches (--from, else each book's own language; installed ones only with --no_download). --list --from eng lists the languages English translates into (installed, downloadable, or through English for another source). Other formats calibre's ebook-convert reads (PDF, DOCX, MOBI, TXT, ...) are converted to EPUB once, before the first language, and translated as EPUB: --from is needed when they carry no language, as PDF and TXT often do. Without -o or --output_dir, each translation is saved beside its book as <name>.<lang>.<ext>, and a book whose translation already exists is skipped (--overwrite to translate it again). The launchers in tools/ run tools/translate_ebook/translate_ebook.py with python_env, nothing to activate, from any folder (relative paths are taken from where it is started):

usage: translate_ebook.py [-h] [-t LANG[,LANG...]] [-f LANG] [-r] [-o OUTPUT] [--output_dir OUTPUT_DIR]
                          [--overwrite] [-m {replace,bilingual}] [--device {cpu,cuda,auto}]
                          [--batch_size BATCH_SIZE] [--no_cache] [--no_download] [--allow_changes] [--list]
                          [books ...]

Translate ebooks offline, out of e2a, with the Argos Translate calibre plugin
(tools/translate_ebook/argostranslate-calibre-plugin.zip). EPUB/AZW3 are translated as they are, the other formats
calibre's ebook-convert reads (PDF, DOCX, MOBI, ...) are converted to EPUB once, before the first
language, and their translations saved as EPUB. It runs on e2a's python_env and argos-translate packages
(models/argos-translate): a language pair e2a already uses is not downloaded again, a missing one is
downloaded on first use (direct or through English). The plugin is installed into e2a's own calibre
profile (run/) on first use, your calibre setup is left untouched.
Translated paths are printed on stdout, progress and logs on stderr.

positional arguments:
  books                 Ebook files (EPUB, AZW3, or PDF, DOCX, MOBI... converted to EPUB first) or folders
                        to translate; @list.txt reads paths from a file, one per line

options:
  -h, --help            show this help message and exit
  -t, --to LANG[,LANG...]
                        Target language(s), ISO-639-1 or ISO-639-3 codes, comma separated for several (fr,
                        fra or fra,ara,spa): one translated ebook per language. all: every language the
                        source reaches (see --list --from), installed ones only with --no_download
  -f, --from LANG       Source language, ISO-639-1 or ISO-639-3 code (default: read from each book)
  -r, --recursive       Also look for books in the subfolders of the given folders
  -o, --output OUTPUT   Output file, single input only, same extension as the input, .epub for a converted
                        one (default: <name>.<lang>.<ext> next to the input)
  --output_dir OUTPUT_DIR
                        Write the translations into this folder (subfolders are mirrored with -r) instead of
                        next to each book
  --overwrite           Translate again even if the output file already exists (skipped otherwise)
  -m, --mode {replace,bilingual}
                        replace: the translation replaces the text. bilingual: each paragraph is followed by
                        its translation, saved as <name>.<lang>.bilingual.<ext> (default: replace)
  --device {cpu,cuda,auto}
                        Device argostranslate runs on (default: cpu)
  --batch_size BATCH_SIZE
                        Segments sent to the translation worker per request (default: 16)
  --no_cache            Neither read nor write the translation cache (run/argos_translate/cache.sqlite), the
                        one that makes a second run of the same book near instant
  --no_download         Never download a missing argos-translate package, fail instead
  --allow_changes       Only when argostranslate is missing from python_env: install it even if packages
                        already there would change version
  --list                List the installed and the downloadable language pairs, then exit. With --from
                        and/or --to: only their pairs, plus the targets a source reaches through English

examples:
  translate_ebook.py book.epub --to fr
  translate_ebook.py book.epub --to fra,ara,spa
  translate_ebook.py book.azw3 --from en --to deu -o /path/to/book_deu.azw3
  translate_ebook.py /path/to/books -r --to es,it --output_dir /path/to/books_translated
  translate_ebook.py book.epub --from eng --to all
  translate_ebook.py @books.txt --to ita --mode bilingual
  translate_ebook.py --list
  translate_ebook.py --list --from eng

Check an audiobook for hallucinations: tools/check_audiobook_hallucinations.py

Lists the sentences of a finished e2a audiobook that do not say their text: babble, a word or a phrase said twice or skipped, mumble before or after the text, a sentence far too long or too short for its text (XTTS and the other autoregressive engines do it now and then). Report only: the audiobook is not changed, you decide what to redo. It reads the .vtt e2a writes beside each audiobook (one cue per sentence), transcribes every sentence with facebook/mms-1b-all (1162 languages, about 4 GB, downloaded into ./models/tts on first use) and compares the letters of both texts, romanized, so any script works. The limits come from the book itself (the medians of all its sentences), names or a hard text raise them for the whole book while a hallucination stands out. Sentences under 10 letters and those still holding digits get the length check only, as does a language MMS does not know. A missing word of 5 letters or more is caught (all 19 in XTTS sentences read with a word left out), once a short window of the audio around it confirms it is not there: the recognizer drops a word at the start or the end of a long sentence that it hears on its own. A missing word of 3 or 4 letters mostly is not: the recognizer drops short words in good audio too. Each flagged sentence is printed as soon as it is found, all of them again in a table at the end, by their block and sentence numbers as e2a numbers them (from 0). Every sentence with its problem, its text, what was heard instead and its measures is saved in <audiobook>.hallucinations.json. While it runs, a sentence is judged on the sentences before it, the table on the whole book: a sentence printed early can be cleared at the end, the line under the table says so. The numbers come from the .vtt (e2a names each cue block <n> sentence <n>); in an audiobook made before, the blocks are counted from its chapters, off after a block left out of the conversion.

usage: check_audiobook_hallucinations.py [-h] [-l LANGUAGE] [--vtt VTT] [-o OUTPUT]
                                         [--device {auto,cpu,cuda,rocm,xpu,mps,jetson}]
                                         audiobooks [audiobooks ...]

Report the sentences of an e2a audiobook that do not say their text: babble, a word or a phrase
said twice or skipped, mumble before or after the text, a sentence too long or too short for its text.
Report only: the audiobook is not changed.
It reads the .vtt e2a writes beside each audiobook (one cue per sentence), transcribes each sentence with
facebook/mms-1b-all (1162 languages, downloaded into models/tts on first use) and compares the letters of
both texts, romanized (uroman, pykakasi for Japanese). The limits come from the book itself, from the
medians of all its sentences: names or a hard text raise them for the whole book, a hallucination stands out.
Each flagged sentence is printed as soon as it is found, all of them in a table at the end, by their block and
sentence numbers as in e2a (from 0). Every sentence with its problem, its text, what was heard and its measures
is saved in <audiobook>.hallucinations.json.

positional arguments:
  audiobooks            Audiobook files (m4b, mp3, flac...) with their .vtt beside them, or folders holding
                        them

options:
  -h, --help            show this help message and exit
  -l LANGUAGE, --language LANGUAGE
                        Language spoken, e2a ISO-639-3 code (default: the audiobook's language tag; set it
                        for a translated book, its tag keeps the ebook's language)
  --vtt VTT             Subtitles of the audiobook, single audiobook only (default: <audiobook>.vtt)
  -o OUTPUT, --output OUTPUT
                        JSON report, single audiobook only (default: <audiobook>.hallucinations.json beside
                        it)
  --device {auto,cpu,cuda,rocm,xpu,mps,jetson}
                        Device the speech recognizer runs on, named as in e2a (default: the one e2a was
                        installed for, cpu when it cannot be used)

examples:
  check_audiobook_hallucinations.py audiobooks/cli/book.m4b
  check_audiobook_hallucinations.py audiobooks/cli/book.m4b --language fra --device cuda
  check_audiobook_hallucinations.py audiobooks/cli

Cloned Voices

You can upload any voice audio in any of the supported audio formats, the ideal duration is around 1 to 5 mn. It doesn't matter if the recording has a noisy background or music playing over it — E2A will clean up the voice for you. The background is removed by demucs (htdemucs) by default, or by the Inworld Voice Isolator on audio.cpp with default_voice_separation_engine = 'voice_isolator' in lib/conf.py (demucs takes over if it cannot run).

The built-in cloned voices list is mainly in English. If you need voices in other languages to be officially added to the list, please contact us and we'll add them after review.

Fine Tuned TTS models

Fine Tune your own TTS model

Universal_TTS_Finetune

De-noise training data

Hugging Face GitHub Repo

Fine Tuned TTS Collection

Hugging Face

For an XTTSv2 custom model a ref audio clip of the voice reference is mandatory:

Your own Ebook2Audiobook customization

You are free to modify libs/conf.py to add or remove the settings you wish. If you plan to do it just make a copy of the original conf.py so on each ebook2audiobook update you will backup your modified conf.py and put back the original one. You must plan the same process for models.py. If you wish to make your own custom model as an official ebook2audiobook fine tuned model so please contact us and we'll add it to the presets list.

Reverting to older Versions

Releases can be found -> here

git checkout tags/VERSION_NUM # Locally/Compose -> Example: git checkout tags/v25.7.7

Common Issues:

***** ROADMAP *****

User Requests

TTS engines

Readme Translation

💻 OS Compatibility


Contributing

Before opening an issue or a pull request, read CONTRIBUTING.md: Python code normalization rules, branch and pull request workflow, GUI legends and README translations, adding a TTS engine, testing.

Hardware donation for beta tests wanted

We accept any kind of hardware to test our development like:

Credits

Special Thanks

To all financial and code contributors, each contribution and suggestion helps to improve the quality of E2A.

ebook2audiobook (DrewThomasson/ebook2audiobook)

gradio
Searching Database…

What is this?A converter that turns DRM-free e-books into audiobooks with chapters and metadata, using TTS engines with optional voice cloning, in 1158+ languages. It runs locally on modest hardware or in Docker.
Is it a web app, a desktop program, or a command-line tool?Both interfaces in one local Python app: launch it and a Gradio web GUI opens in your browser, or drive it headless from the terminal. Windows, macOS and Linux are supported, plus official Docker images.
How do I get it running?Clone the repo and run ebook2audiobook.cmd on Windows or the Mac launcher .command — the scripts auto-install missing dependencies (scoop on Windows, homebrew on macOS) — then open the URL printed in the terminal. Alternatively use the ready Docker images for CPU, CUDA or ROCm, with the GUI on port 7860.
Any gotchas before I convert my library?The authors' notice limits it to non-DRM, legally acquired e-books. Also, EPUB has no standard structure, so manually remove any text you don't want narrated before converting.
Do I need a powerful GPU for this?No — 2 GB RAM / 1 GB VRAM minimum (8 GB / 4 GB recommended). It runs on plain CPU with optional CUDA, ROCm, Jetson, Intel/AMD/ARM XPU or Apple Silicon MPS acceleration, but modern TTS engines are slow on CPU, so weaker machines should use faster engines like YourTTS or Tacotron2.
Which TTS engines does it use under the hood?Eight built-in engines: XTTSv2, Bark, Fairseq, VITS, Tacotron2, Tortoise, GlowTTS and YourTTS. You can also plug in your own trained model as a .zip (XTTSv2, VITS, FAIRSEQ, PIPER and others on request), and the E2A team shares fine-tuned preset models.
What formats can it read, and what does it save?It reads about 20 input formats — .epub, .pdf, .mobi, .txt, .html, .rtf, .docx, .odt, comics archives like .cbr and .cbz — plus OCR for scanned-image pages. Output is .m4b, .m4a, .mp3, .flac, .wav, .ogg and other containers, mono or stereo. Use .epub or .mobi for the best automatic chapter detection.
Can it narrate books in my own voice?Yes — voice cloning is optional: pass a --voice file on the command line or select it in the GUI and the narration follows that voice. A custom XTTS model always uses its ref.wav sample as the voice.
How do I control the narration style, like pauses or voice switches?With SML tags in the text: [break] and [pause] add short silences, [pause:N] a fixed pause of N seconds, and [voice:...] switches the voice for a passage. The companion E2A-SML repo adds these tags to an e-book automatically.
Size
77.8 MB
Stars
20.7K
Age
2y
Commits · 90 Days