CPU/GPU Converter from E-Book to audiobook with chapters and metadata
using advanced TTS engines and much more.
Supports voice cloning and 1158 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.
New Default Voice Demo
Sherlock.mp4
More Demos
ASMR Voice
WhisperASMR-Demo.mp4
Rainy Day Voice
Rainy_Day_voice_Demo.mp4
Scarlett Voice
ScarlettJohansson-Demo.mp4
David Attenborough Voice
shortStory.mp4
Example
- π§ TTS Engines supported:
XTTSv2,Bark,Fairseq,VITS,Tacotron2,Tortoise,GlowTTS,YourTTS,Fish Speech 1.5,CosyVoice 3,Qwen3-TTS - π Convert multiple file formats:
.epub,.mobi,.azw3,.fb2,.lrf,.rb,.snb,.tcr,.pdf,.txt,.rtf,.doc,.docx,.html,.odt,.azw,.tiff,.tif,.png,.jpg,.jpeg,.bmp - π» TextArea to convert directly a short text in audio
- π OCR scanning for files with text pages as images
- π High-quality text-to-speech from near realtime to near real voice
- π£οΈ Optional voice cloning using your own voice file
- π Supports 1158 languages (supported languages list)
- π» Low-resource friendly β runs on 2 GB RAM / 1 GB VRAM (minimum)
- π΅ Audiobook output formats: mono or stereo
aac,flac,mp3,m4b,m4a,mp4,mov,ogg,wav,webm - π§ SML tags supported β fine-grained control of breaks, pauses, voice switching and more (see below)
- π§© Optional custom model using your own trained model (XTTSv2 only, other on request)
- ποΈ Fine-tuned preset models trained by the E2A Team
(Contact us if you need additional fine-tuned models, or if you'd like to share yours to the official preset list) - π Modern React/FastAPI Web UI β full conversion flow, live SSE progress, audiobook library, and session resume (see below)
- β‘ Significantly faster GPU inference β all 9 engines optimized for throughput on RTX 30/40-series and equivalent (see below)
- π Fish Speech 1.5 β new high-quality zero-shot voice cloning engine (~88β92% similarity); non-commercial use only (CC-BY-NC-SA-4.0)
- π€ CosyVoice 3 β zero-shot voice cloning with cross-lingual and instruct mode (dialect/emotion/speed control); Apache 2.0, commercial use allowed (FunAudioLLM/CosyVoice)
- π€ Qwen3-TTS β zero-shot voice cloning via Alibaba's Qwen3 transformer TTS; Apache 2.0, commercial use allowed (QwenLM/Qwen3-TTS)
- 2GB RAM min, 8GB recommended.
- 1GB VRAM min, 4GB recommended.
- Virtualization enabled if running on windows (Docker only).
- CPU, XPU (intel, AMD, ARM)*.
- CUDA, ROCm, JETSON
- MPS (Apple Silicon CPU)
* Modern TTS engines are very slow on CPU, so use lower quality TTS like YourTTS, Tacotron2 etc..
| Arabic (ar) | Chinese (zh) | English (en) | Spanish (es) |
|---|---|---|---|
| French (fr) | German (de) | Italian (it) | Portuguese (pt) |
| Polish (pl) | Turkish (tr) | Russian (ru) | Dutch (nl) |
| Czech (cs) | Japanese (ja) | Hindi (hi) | Bengali (bn) |
| Hungarian (hu) | Korean (ko) | Vietnamese (vi) | Swedish (sv) |
| Persian (fa) | Yoruba (yo) | Swahili (sw) | Indonesian (id) |
| Slovak (sk) | Croatian (hr) | Tamil (ta) | Danish (da) |
.epub,.pdf,.mobi,.txt,.html,.rtf,.chm,.lit,.pdb,.fb2,.odt,.cbr,.cbz,.prc,.lrf,.pml,.snb,.cbc,.rb,.tcr- Best results:
.epubor.mobifor automatic chapter detection
.m4b,.m4a,.mp4,.webm,.mov,.mp3,.flac,.wav,.ogg,.aac- Process format can be changed in lib/conf.py
[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
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.
-
Clone repo
git clone https://github.com/DrewThomasson/ebook2audiobook.git cd ebook2audiobook -
Install / Run ebook2audiobook:
-
Linux/MacOS
./ebook2audiobook.command
Note for MacOS users: homebrew is installed to install missing programs.
-
Mac Launcher
Double clickMac Ebook2Audiobook Launcher.command -
Windows
ebook2audiobook.cmd
or Double click
ebook2audiobook.cmdNote for Windows users: scoop is installed to install missing programs without administrator privileges.
-
-
Open the Web App: Click the URL provided in the terminal to access the web app and convert eBooks.
http://localhost:7860/ -
For Public Link:
./ebook2audiobook.command --share(Linux/MacOS)ebook2audiobook.cmd --share(Windows)python app.py --share(all OS)
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.
-
Linux/MacOS:
./ebook2audiobook.command --headless --ebook <path_to_ebook_file> --voice <path_to_voice_file> --language <language_code>
-
Windows
ebook2audiobook.cmd --headless --ebook <path_to_ebook_file> --voice <path_to_voice_file> --language <language_code>
-
[--ebook]: Path to your eBook file
-
[--voice]: Voice cloning file path (optional)
-
[--language]: Language code in ISO-639-3 (i.e.: ita for italian, eng for english, deu for german...).
Default language is eng and --language is optional for default language set in ./lib/lang.py.
The ISO-639-1 2 letters codes are also supported.
(must be a .zip file containing the mandatory model files. Example for XTTSv2: config.json, model.pth, vocab.json and ref.wav)
-
Linux/MacOS
./ebook2audiobook.command --headless --ebook <ebook_file_path> --language <language> --custom_model <custom_model_path>
-
Windows
ebook2audiobook.cmd --headless --ebook <ebook_file_path> --language <language> --custom_model <custom_model_path>
Note: the ref.wav of your custom model is always the voice selected for the conversion
-
<custom_model_path>: Path to
model_name.zipfile, which must contain (according to the tts engine) all the mandatory files
(see ./lib/models.py).
- Linux/MacOS
./ebook2audiobook.command --help
- Windows
ebook2audiobook.cmd --help
- Or for all OS
python app.py --help
usage: app.py [-h] [--session SESSION] [--share] [--headless] [--ebook EBOOK] [--ebooks_dir EBOOKS_DIR]
[--language LANGUAGE] [--voice VOICE] [--device {CPU,CUDA,MPS,ROCM,XPU,JETSON}]
[--tts_engine {XTTSv2,BARK,VITS,FAIRSEQ,TACOTRON2,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 options are for all modes:
Optional
**** The following option are for gradio/gui mode only:
Optional
--share 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:
--voice VOICE (Optional) Path to the voice cloning file for TTS engine.
Uses the default voice if not present.
--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 {XTTSv2,BARK,VITS,FAIRSEQ,TACOTRON2,YOURTTS,xtts,bark,vits,fairseq,tacotron,yourtts}
(Optional) Preferred TTS engine (available are: ['XTTSv2', 'BARK', 'VITS', 'FAIRSEQ', 'TACOTRON2', 'YOURTTS', 'FISHSPEECH', 'xtts', 'bark', 'vits', 'fairseq', 'tacotron', 'yourtts', 'fishspeech'].
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
--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
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
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.
- Clone the Repository:
git clone https://github.com/DrewThomasson/ebook2audiobook.git
cd ebook2audiobook- 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- Run the Container:
Docker run image:
Gradio/GUI:
CPU:
docker run -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" --rm -it -p 7860:7860 athomasson2/ebook2audiobook:cpu
CUDA:
docker run -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" --gpus all --rm -it -p 7860:7860 athomasson2/ebook2audiobook:cu[118/122/124/126 etc..]
ROCM:
docker run -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" --device=/dev/kfd --device=/dev/dri --rm -it -p 7860:7860 athomasson2/ebook2audiobook:rocm[6.0/6.1/6.4 etc..]
XPU:
docker run -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" --device=/dev/dri --rm -it -p 7860:7860 athomasson2/ebook2audiobook:xpu
JETSON:
docker run -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" --runtime nvidia --rm -it -p 7860:7860 athomasson2/ebook2audiobook:jetson[51/60/61 etc...]
Headless mode:
CPU:
docker run -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "/my/real/ebooks/folder/absolute/path:/app/another_ebook_folder" --rm -it -p 7860:7860 ebook2audiobook:cpu --headless --ebook "/app/another_ebook_folder/myfile.pdf" [--voice /app/my/voicepath/voice.mp3 etc..]
CUDA:
docker run -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "/my/real/ebooks/folder/absolute/path:/app/another_ebook_folder" --gpus all --rm -it -p 7860:7860 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 -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "/my/real/ebooks/folder/absolute/path:/app/another_ebook_folder" --device=/dev/kfd --device=/dev/dri --rm -it -p 7860:7860 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 -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "/my/real/ebooks/folder/absolute/path:/app/another_ebook_folder" --device=/dev/dri --rm -it -p 7860:7860 ebook2audiobook:xpu --headless --ebook "/app/another_ebook_folder/myfile.pdf" [--voice /app/my/voicepath/voice.mp3 etc..]
JETSON:
docker run -v "./ebooks:/app/ebooks" -v "./audiobooks:/app/audiobooks" -v "./models:/app/models" -v "./voices:/app/voices" -v "./tmp:/app/tmp" -v "/my/real/ebooks/folder/absolute/path:/app/another_ebook_folder" --runtime nvidia --rm -it -p 7860:7860 ebook2audiobook:jetson[51/60/61 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 gpu up --no-log-prefix
Run Headless mode:
DEVICE_TAG=cu128 docker compose --profile gpu run --rm ebook2audiobook --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 gpu up
Run Headless mode:
DEVICE_TAG=cu128 podman-compose -f podman-compose.yml --profile gpu run --rm ebook2audiobook-gpu --headless --ebook "/app/ebooks/myfile.pdf" --voice /app/voices/eng/adult/female/some_voice.wav etc..- NOTE: MPS is not exposed in docker so CPU must be used
- My NVIDIA GPU isn't being detected?? -> GPU ISSUES Wiki Page
For an XTTSv2 custom model a ref audio clip of the voice reference is mandatory:
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.
Releases can be found -> here
git checkout tags/VERSION_NUM # Locally/Compose -> Example: git checkout tags/v25.7.7- My NVIDIA/ROCm/XPU/MPS GPU isn't being detected?? -> GPU ISSUES Wiki Page
- CPU is slow (better on server smp CPU) while GPU can have almost real time conversion. Discussion about this For faster multilingual generation I would suggest my other project that uses piper-tts instead (It doesn't have zero-shot voice cloning though, and is Siri quality voices, but it is much faster on cpu).
- "I'm having dependency issues" - Just use the docker, its fully self contained and has a headless mode,
add
--helpparameter at the end of the docker run command for more information. - "Im getting a truncated audio issue!" - PLEASE MAKE AN ISSUE OF THIS, we don't speak every language and need advise from users to fine tune the sentence splitting logic.π
- Any help from people speaking any of the supported languages to help us improve the models
A second, fully standalone web interface built with React + TypeScript + Tailwind (frontend) and FastAPI (backend, port 8000) ships alongside the existing Gradio UI.
- Upload β Configure β Chapters Editor β Convert β Library β guided single-page flow
- Live progress via Server-Sent Events (SSE) β per-sentence status streamed to the browser without polling
- Voice Browser & Preview β browse and audition built-in voices before committing
- Audiobook Library β completed audiobooks and in-progress sessions listed with date, UUID, and a Finish & Combine button for sessions that completed TTS but lost the final combine step
- Session resume β sessions survive server restarts; incomplete conversions can be continued exactly where they left off
- REST API
POST /api/sessionsβ create session (upload ebook)GET /api/sessions/{id}/eventsβ SSE streamPOST /api/sessions/{id}/combineβ combine chapter audio for a stalled sessionDELETE /api/sessions/{id}β clean up tmp files, proc dir, and uploaded ebook
# Backend (from repo root)
uvicorn webui.backend.main:app --port 8000 --reload
# Frontend (first time: npm install)
cd webui/frontend
npm run dev # dev server on :5173
npm run build # production build β dist/The three optional high-quality engines β Fish Speech 1.5, CosyVoice 3, and Qwen3-TTS β are not bundled in the default install because they carry large or conflicting dependencies. Each engine has a dedicated Windows installer script; Linux/macOS users can follow the manual steps below.
Each installer wipes and reinstalls
python_env/dependencies so the engine's specific torch version is in place. Run only one installer at a time β the profiles are mutually exclusive (except Fish Speech 1.5, which shares the regular profile).
Zero-shot voice cloning (~88β92% similarity). Non-commercial use only (CC-BY-NC-SA-4.0).
Fish Speech is included in the regular profile alongside the other 9 engines.
Windows β run the regular installer (already includes Fish Speech):
1_regular_engines_install.cmdLinux / macOS:
# --no-deps bypasses lightning>=2.1.0 which has no Python 3.12 wheel on PyPI;
# all runtime deps (torch, torchaudio, transformers) are already installed.
pip install --no-deps "git+https://github.com/fishaudio/fish-speech.git@v1.5.1"The Fish Speech 1.5 option appears in the engine dropdown automatically once installed.
Zero-shot voice cloning with cross-lingual and instruct mode. Apache 2.0, commercial use allowed.
Note: CosyVoice requires
torch 2.3.1+cu121, which conflicts with the regular engines'torch 2.7.1+cu128. Running2_cosy_voice_engine_install.cmdswitches the entire environment. See upstream issue #1422 for known dependency status.
Step 1 β clone the third-party repo (one-time):
git clone --recursive https://github.com/FunAudioLLM/CosyVoice third_party/CosyVoiceStep 2 β Windows:
2_cosy_voice_engine_install.cmdStep 2 β Linux / macOS:
pip install torch==2.3.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121
pip install -r third_party/CosyVoice/requirements.txt
pip install hyperpyyaml
echo "cosyvoice" > .engine-modeThe CosyVoice 3 option will appear in the engine dropdown once .engine-mode contains cosyvoice.
Zero-shot voice cloning via Alibaba's Qwen3 transformer TTS. Apache 2.0, commercial use allowed.
Requirements: ~6 GB VRAM (bfloat16), CUDA 11.8+. Model weights (~3 GB) download automatically from HuggingFace on first inference.
Windows:
3_qwen3tts_engine_install.cmdLinux / macOS:
pip install -U qwen-tts
echo "qwen3tts" > .engine-modeThe Qwen3-TTS option will appear in the engine dropdown once .engine-mode contains qwen3tts. Select a reference voice (.wav) in the Voice field β Qwen3-TTS clones the speaker style from that file without requiring a transcript.
Supported languages: Arabic, German, English, French, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Chinese.
To switch back to the regular engines at any time:
1_regular_engines_install.cmdAll 9 TTS engines (XTTSv2, Bark, VITS, Fairseq, Tacotron2, Tortoise, GlowTTS, YourTTS, Fish Speech 1.5) received GPU inference optimizations. The changes are cumulative and hardware-adaptive β they activate only when the detected GPU supports them.
The single biggest speedup. Previously each engine shuffled its full model weight set GPUβCPUβGPU on every sentence (or even every sub-sentence part). The model is now moved to the target device once per conversion job and stays there.
On a typical RTX 40-series card a 1.8 GB model (e.g. XTTSv2) costs ~110 ms per transfer direction over PCIe. For a 10,000-sentence audiobook the old behaviour wasted ~36 minutes of pure memory transfer with zero benefit. That overhead is now zero.
Replaced torch.no_grad() with torch.inference_mode() across every engine's hot path. inference_mode additionally disables per-tensor version-counter tracking, saving ~10% wall-clock on autoregressive models with long token sequences.
Enabled at engine load time, conditioned on runtime GPU detection:
| Feature | Condition | Benefit |
|---|---|---|
| TF32 matmul | CUDA, CC β₯ 8.0 (RTX 30xx/40xx), non-Jetson | Native tensor-core throughput for FP32 ops |
| TF32 cuDNN | Same | Convolution speedup |
| Flash SDP | CC β₯ 8.0 | Hardware-fused attention, lower memory bandwidth |
| Memory-Efficient SDP | CC β₯ 8.0 | Reduced VRAM for large attention matrices |
| BF16 autocast | CC β₯ 8.0, non-Windows | Halved memory, tensor-core paths for matmul |
| FP16 autocast | CC β₯ 7.0, or Windows | Safe precision reduction on older / Windows targets |
All flags are wrapped in try/except and fall back silently to FP32 on unsupported hardware.
Applied to XTTSv2 after checkpoint load when running on GPU (PyTorch β₯ 2.0). The model graph is compiled into fused CUDA kernels on the first inference call (mode='reduce-overhead', fullgraph=False to tolerate XTTS dynamic control flow). Pays a ~30 s warmup on sentence 1; all subsequent sentences skip Python dispatch overhead entirely.
- Invariant hoisting β
fine_tuned_paramsdict,language_iso1,amp_enabled, andsampleratewere rebuilt on every sentence-part; now computed once perconvert()call. - SML fast-path β
_split_sentence_on_sml()skips the regexfinditerentirely when the sentence contains no[character (the common case for plain prose). - Silence tensor cache β silence-break tensors (~10β30 KB each) were freshly allocated for every sentence-part. Now cached by sample count and reused. Eliminates ~300 MB of allocation churn on a 10,000-sentence book.
- Pre-compiled regex β the trailing-word check
r'\w$'is compiled once at module load rather than on every sentence-part. - O(1) dict membership β
key in dictreplaceskey in dict.keys()throughout all engine hot paths.
cleanup_memory() (which calls torch.cuda.empty_cache() + Windows working-set trim) previously ran unconditionally before every model load, even when the model was already warm in the cache. It now runs only on genuine cold loads.
Changed default_audio_proc_format from flac to wav in lib/conf.py. FLAC encoding is CPU-bound; for thousands of per-sentence segment files it added measurable latency between GPU inference calls. WAV is a direct PCM dump β zero encoding overhead.
XTTSv2 and Bark attempt deepspeed.init_inference() after model load when DeepSpeed is installed. On systems with the full CUDA Toolkit this enables kernel-injected, multi-precision inference fusion. On systems without DeepSpeed (or without nvcc) the engines fall back to standard PyTorch automatically β no configuration required.
- Coqui TTS: Coqui TTS GitHub
- Calibre: Calibre Website
- FFmpeg: FFmpeg Website
- @shakenbake15 for better chapter saving method




