Sign inSign up

athomasson2/ebook2audiobookstyletts2

By athomasson2

•Updated about 2 years ago

This will launch a web gui for generating audiobooks with Styletts2 + voice cloning

Image
Machine learning & AI
0

1.8K

athomasson2/ebook2audiobookstyletts2 repository overview

⁠📚 eBook to Audiobook Converter with Styletts2

Convert eBooks to audiobooks effortlessly using a Docker container. This project leverages Calibre for eBook conversion and Styletts2 for text-to-speech, all wrapped in a Gradio interface.

⁠🌟 Features

  • eBook Conversion: Converts various eBook formats to text using Calibre.
  • Text-to-Speech: High-quality TTS using eSpeak-ng with customizable voice, speed, and pitch.
  • Language Support: Only English
  • User-Friendly Interface: Easy-to-use Gradio interface accessible via your web browser.
  • Dockerized: Run the entire setup with a single Docker command.
  • Voice Cloning: You clone any voice by providing a sample audio of them speaking as mp3 or wav file.

⁠🎥 Demo

Demo⁠

⁠🖥️ Gradio Web Gui

Screenshot 2024-08-27 at 7 23 48 PM Screenshot 2024-08-27 at 7 24 05 PM

⁠🚀 Quick Start

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.

⁠🎛️ Gradio Interface Customizations

In the Gradio interface, you can customize the following settings for your audiobook conversion:

  • Voice Cloning: Choose a voice from any wav or mp3 sample you have on hand.
  • Audiobook Player: Listen to the converted audiobook directly in the interface.
  • Download Audiobook: Download the generated audiobook files directly to your device.

⁠🛠️ Building the Docker Image

If you prefer to build the Docker image yourself, use the following Dockerfile:

# Use an official Python 3.10 image as the base
FROM python:3.10-slim

# Install system dependencies for Calibre and ffmpeg
RUN apt-get update && \
    apt-get install -y calibre ffmpeg git nano wget unzip git && \
    rm -rf /var/lib/apt/lists/*

# Install Python packages
RUN pip install --no-cache-dir styletts2 pydub nltk beautifulsoup4 ebooklib tqdm spacy gradio

# Set the working directory
WORKDIR /app

# Copy the current directory contents into the container
#COPY . .

#No do a git clone instead
RUN git clone https://github.com/DrewThomasson/ebook2audiobookSTYLETTS2.git

# Download the spaCy language model
RUN python -m spacy download en_core_web_sm

# Replace the NLTK folder with the backup
RUN echo "Replacing the nltk folder with the nltk folder backup I pulled from a docker image, just in case the nltk servers ever mess up." && \
    ZIP_URL="https://github.com/DrewThomasson/VoxNovel/blob/main/readme_files/nltk.zip?raw=true" && \
    TARGET_DIR="/usr/local/lib/python3.10/site-packages" && \
    TEMP_DIR=$(mktemp -d) && \
    wget -q -O "$TEMP_DIR/nltk.zip" "$ZIP_URL" && \
    unzip -q "$TEMP_DIR/nltk.zip" -d "$TEMP_DIR" && \
    rm -rf "$TARGET_DIR/nltk" && \
    mv "$TEMP_DIR/nltk" "$TARGET_DIR/nltk" && \
    rm -rf "$TEMP_DIR" && \
    echo "NLTK Files Replacement complete."

# Run the test script
RUN python ebook2audiobookSTYLETTS2/styletts2_test.py

# Default command
CMD ["python", "ebook2audiobookSTYLETTS2/Gradio_GUI.py"]
#To run this docker on your computer run docker run -it athomasson2/ebook2audiobookstyletts2

To build the image, run:

docker build --platform linux/amd64 -t athomasson2/ebook2audiobookstyletts2:latest .

⁠🎉 Enjoy

Explore the full power of this converter by running your Docker container. Customize the settings in the Gradio interface to suit your needs.

For more details and updates, visit the GitHub repository⁠.

⁠🙏 Special Thanks

Tag summary

Content type

Image

Digest

sha256:1c947090f…

Size

4.6 GB

Last updated

about 2 years ago

docker pull athomasson2/ebook2audiobookstyletts2