Spaces:
Sleeping
title: Ebook2audiobookXTTS
emoji: πΈπ
colorFrom: red
colorTo: yellow
sdk: gradio
sdk_version: 4.44.0
app_file: app.py
pinned: false
license: mit
short_description: Convert any Ebook to AudioBook with Xtts + VoiceCloning!
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
π ebook2audiobookXTTS
Convert eBooks to audiobooks with chapters and metadata using Calibre and Coqui XTTS. Supports optional voice cloning and multiple languages!
π Features
- π Converts eBooks to text format with Calibre.
- π Splits eBook into chapters for organized audio.
- ποΈ High-quality text-to-speech with Coqui XTTS.
- π£οΈ Optional voice cloning with your own voice file.
- π Supports multiple languages (English by default).
- π₯οΈ Designed to run on 4GB RAM.
π οΈ Requirements
- Python 3.x
coqui-tts
Python package- Calibre (for eBook conversion)
- FFmpeg (for audiobook creation)
- Optional: Custom voice file for voice cloning
π§ Installation Instructions
Install Python 3.x from Python.org.
Install Calibre:
- Ubuntu:
sudo apt-get install -y calibre
- macOS:
brew install calibre
- Windows (Admin Powershell):
choco install calibre
- Ubuntu:
Install FFmpeg:
- Ubuntu:
sudo apt-get install -y ffmpeg
- macOS:
brew install ffmpeg
- Windows (Admin Powershell):
choco install ffmpeg
- Ubuntu:
Optional: Install Mecab (for non-Latin languages):
- Ubuntu:
sudo apt-get install -y mecab libmecab-dev mecab-ipadic-utf8
- macOS:
brew install mecab
,brew install mecab-ipadic
- Windows (Admin Powershell):
choco install mecab
(Note: Japanese support is limited)
- Ubuntu:
Install Python packages:
pip install tts==0.21.3 pydub nltk beautifulsoup4 ebooklib tqdm
For non-Latin languages:
python -m unidic download pip install mecab mecab-python3 unidic
π Supported Languages
- English (en)
- Spanish (es)
- French (fr)
- German (de)
- Italian (it)
- Portuguese (pt)
- Polish (pl)
- Turkish (tr)
- Russian (ru)
- Dutch (nl)
- Czech (cs)
- Arabic (ar)
- Chinese (zh-cn)
- Japanese (ja)
- Hungarian (hu)
- Korean (ko)
Specify the language code when running the script.
π Usage
π₯οΈ Gradio Web Interface
Run the Script:
python custom_model_ebook2audiobookXTTS_gradio.py
Open the Web App: Click the URL provided in the terminal to access the web app and convert eBooks.
π Basic Usage
python ebook2audiobook.py <path_to_ebook_file> [path_to_voice_file] [language_code]
- : Path to your eBook file.
- [path_to_voice_file]: Optional for voice cloning.
- [language_code]: Optional to specify language.
𧩠Custom XTTS Model
python custom_model_ebook2audiobookXTTS.py <ebook_file_path> <target_voice_file_path> <language> <custom_model_path> <custom_config_path> <custom_vocab_path>
- : Path to your eBook file.
- : Optional for voice cloning.
- : Optional to specify language.
- : Path to
model.pth
. - : Path to
config.json
. - : Path to
vocab.json
.
π³ Using Docker
You can also use Docker to run the eBook to Audiobook converter. This method ensures consistency across different environments and simplifies setup.
π Running the Docker Container
To run the Docker container and start the Gradio interface, use the following command:
-Run with CPU only
docker run -it --rm -p 7860:7860 athomasson2/ebook2audiobookxtts:latest
-Run with GPU Speedup (Nvida graphics cards only)
docker run -it --rm --gpus all -p 7860:7860 athomasson2/ebook2audiobookxtts:latest
This command will start the Gradio interface on port 7860.(localhost:7860)
π₯οΈ Docker GUI
π οΈ For Custom Xtts Models
Models built to be better at a specific voice. Check out my Hugging Face page here.
To use a custom model, paste the link of the Finished_model_files.zip
file like this:
David Attenborough fine tuned Finished_model_files.zip
More details can be found at the Dockerfile Hub Page.
π Fine Tuned Xtts models
To find already fine-tuned XTTS models, visit this Hugging Face link π. Search for models that include "xtts fine tune" in their names.
π₯ Demos
https://github.com/user-attachments/assets/8486603c-38b1-43ce-9639-73757dfb1031
π Supported eBook Formats
.epub
,.pdf
,.mobi
,.txt
,.html
,.rtf
,.chm
,.lit
,.pdb
,.fb2
,.odt
,.cbr
,.cbz
,.prc
,.lrf
,.pml
,.snb
,.cbc
,.rb
,.tcr
- Best results:
.epub
or.mobi
for automatic chapter detection
π Output
π Special Thanks
- Coqui TTS: Coqui TTS GitHub
- Calibre: Calibre Website