DrewThomasson / ebook2audiobookpiper-tts

Converts ebooks into audiobooks with piper-tts
MIT License
17 stars 2 forks source link
audiobook-creator audiobooks docker multilingual piper-tts tts

📚 eBook to Audiobook Converter with Piper-tts

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

🌟 Features

🌐 Supported Languages

🎥 Demo

https://github.com/user-attachments/assets/7d2328b9-ac65-4485-b1b3-fe1006f041c6

🖥️ Gradio Web Gui

Screenshot 2024-08-30 at 12 17 41 AM Screenshot 2024-08-30 at 12 17 51 AM

Open in free google colab!

Free Google Colab

🚀 Quick Start

To quickly get started with this eBook to Audiobook converter, simply run the following Docker command:

docker run -it -p 7860:7860 --platform=linux/amd64 registry.hf.space/drewthomasson-ebook2audiobookpiper-tts:latest python app.py 

With Nvidia GPU

docker run -it --gpus all -p 7860:7860 --platform=linux/amd64 registry.hf.space/drewthomasson-ebook2audiobookpiper-tts-gpu:latest python app.py

This will start the Gradio interface on port 7860. You can access it by navigating to http://localhost:7860 in your web browser.

🌐 Offline Mode

For a fully offline experience with all Piper TTS voice models bundled, use the following Docker command:

docker run -it --rm -p 7860:7860 athomasson2/ebook2audiobookpiper-tts:latest_large

This version comes preloaded with every Piper TTS voice model, ensuring that you can convert eBooks to audiobooks without needing an internet connection. Perfect for uninterrupted usage in any environment!

🎛️ Gradio Interface Customizations

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

🛠️ Building the Docker Image

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

# Use an official Python runtime as a parent image
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/*

# Set the working directory
WORKDIR /app

#No do a git clone instead
RUN git clone https://github.com/DrewThomasson/ebook2audiobookpiper-tts.git

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

# 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."

# Set the working directory
WORKDIR /app/ebook2audiobookpiper-tts

# NO USE THIS Default command
CMD ["python", "gradio_gui.py"]
#To run this docker on your computer run docker run -it athomasson2/ebook2audiobookpiper-tts

To build the image, run:

docker build -t athomasson2/ebook2audiobookpiper-tts: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 DockerHub repository.

🙏 Special Thanks