This program uses Calibre for converting eBooks into chapters and StyleTTS2 to transform these chapters into an audiobook.
It features text-to-speech technology with an optional voice cloning capability if a voice file is provided.
chapter_0.mp4
.epub, .pdf, .mobi, .txt, .html, .rtf, .chm, .lit, .pdb, .fb2, .odt, .cbr, .cbz, .prc, .lrf, .pml, .snb, .cbc, .rb, and .tcr, (Best results are from using epub or mobi for auto chapter detection)
outputs as a m4b with all book metadata and chapters, example output file in an audiobook player app
- Converts eBooks to text format using Calibre's
ebook-convert
tool. - Splits the eBook into chapters for easier processing.
- Utilizes
StyleTTS2
for converting each chapter into an audio file. - Offers an optional voice cloning feature when provided with a voice file.
To quickly get started with this eBook to Audiobook converter, simply run the following Docker command:
To run the Docker container and start the Gradio interface, use the following command:
To run with a gpu
docker run -it --rm --gpus all -p 7860:7860 athomasson2/ebook2audiobookstyletts2:latest
To run without a gpu
docker run -it --rm -p 7860:7860 athomasson2/ebook2audiobookstyletts2:latest
This will start the Gradio interface on port 7860
. You can access it by navigating to http://localhost:7860
in your web browser.
- Python 3.10
styletts2
Python package- Calibre (for eBook conversion)
- FFmpeg (for audiobook file creation)
- Optional: Voice file for voice cloning
- 4gb ram
- Install Python 3.x from Python.org.
- Calibre:
- Ubuntu:
sudo apt-get install -y calibre
- macOS:
brew install calibre
- Windows(Powershell in Administrator mode):
choco install calibre
- Ubuntu:
- FFmpeg:
- Ubuntu:
sudo apt-get install -y ffmpeg
- macOS:
brew install ffmpeg
- Windows(Powershell in Administrator mode)s:
choco install ffmpeg
- Ubuntu:
- Python packages:
pip install styletts2 pydub nltk beautifulsoup4 ebooklib tqdm
Navigate to the script's directory in the terminal and use one of the following commands:
python styletts_to_ebook.py <path_to_ebook_file>
Replace <path_to_ebook_file> with the path to your eBook file.
python styletts_to_ebook.py <path_to_ebook_file> <path_to_voice_file>
Replace <path_to_ebook_file> with the path to your eBook file.
Replace <path_to_voice_file> with the path to the voice file for cloning.