### Install sitecustomize.py hook Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/Notebooks/colab_ebook2audiobook.ipynb Installs the sitecustomize.py hook. This is a setup step for the project. ```python print("\n--- Step 4: Installing sitecustomize.py hook ---") install_sitecustomize() ``` -------------------------------- ### Install num2words from source Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/ext/py/num2words/README.rst Alternatively, install num2words by downloading the source package and running the setup script. ```bash python setup.py install ``` -------------------------------- ### Local Installation Steps Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/tools/E2A-SML/README.md Steps to install the SML Book Dialog Extractor locally, including cloning the repository, setting up the environment, and installing dependencies. ```bash git clone https://github.com/DrewThomasson/ebook2audiobook.git cd ebook2audiobook ./ebook2audiobook.command #Mac/Linux or ebook2audiobook.cmd #Window | locally install ebook2audiobook first conda activate ./python_env # Activate the created python env for E2A cd ebook2audiobook/tools/E2A-SML # Go into E2A dir pip install -r requirements.txt # Install additional requirments for E2A SML python -m spacy download en_core_web_sm # Download en_core_web_sm ``` -------------------------------- ### Run ebook2audiobook on Linux/MacOS Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/README.md Execute this command to start the ebook2audiobook application on Linux or MacOS. Homebrew is used to install any missing dependencies. ```bash ./ebook2audiobook.command ``` -------------------------------- ### Run ebook2audiobook on Windows Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/README.md Execute this command to start the ebook2audiobook application on Windows. Scoop is used to install any missing dependencies without requiring administrator privileges. ```bash ebook2audiobook.cmd ``` -------------------------------- ### Install Python Packages for ebook2audiobook Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/Notebooks/kaggle-ebook2audiobook.ipynb Manages Python package installations, starting with upgrading pip, setuptools, and wheel. It then installs llvmlite and numba using pre-built binaries, followed by all requirements from the project's requirements.txt file. Finally, it downloads the Unidic dictionary data. ```bash python3 -m pip install -q --upgrade pip setuptools wheel ``` ```bash python3 -m pip install -q --upgrade llvmlite numba --only-binary=:all: ``` ```bash python3 -m pip install -q --upgrade --no-cache-dir -r /kaggle/working/ebook2audiobook/requirements.txt ``` ```bash python3 -m unidic download ``` -------------------------------- ### Run num2words test suite Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/ext/py/num2words/README.rst Execute the library's test suite using the setup script. This is a basic test run. ```bash python setup.py test ``` -------------------------------- ### Install OS Packages for ebook2audiobook Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/Notebooks/kaggle-ebook2audiobook.ipynb Installs essential system packages required for the ebook2audiobook project, including libraries for Calibre, ffmpeg, mediainfo, nodejs, espeak-ng, sox, Tesseract OCR, and mecab for Japanese text analysis. Also installs Rust, which is a dependency for some Python packages. ```bash apt-get update -qq ``` ```bash apt-get install -y -qq libxcb-cursor0 libegl1 libopengl0 ``` ```bash sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin ``` ```bash apt-get install -y -qq ffmpeg ``` ```bash apt-get install -y -qq mediainfo ``` ```bash apt-get install -y -qq nodejs ``` ```bash apt-get install -y -qq espeak-ng ``` ```bash apt-get install -y -qq sox ``` ```bash apt-get install -y -qq tesseract-ocr tesseract-ocr-eng ``` ```bash apt-get install -y -qq mecab libmecab-dev mecab-ipadic-utf8 ``` ```bash curl -fsSL https://sh.rustup.rs | sh -s -- -y --quiet && echo 'source $HOME/.cargo/env' >> ~/.bashrc ``` -------------------------------- ### Install Testing Requirements Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/ext/py/num2words/num2words/README.md Before contributing, install the necessary packages for testing by running this pip command. This ensures your code meets the project's quality standards. ```bash pip install -r requirements-test.txt ``` -------------------------------- ### Run Pre-built Docker Container (CPU) Source: https://github.com/drewthomasson/ebook2audiobook/wiki/Manual-Docker-Guide Starts the Gradio interface on port 7860. Add `--help` for more options. ```powershell docker run --pull always --rm -p 7860:7860 athomasson2/ebook2audiobook:cpu ``` -------------------------------- ### Install System Packages for ebook2audiobook Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/Notebooks/colab_ebook2audiobook.ipynb Installs essential system packages required for ebook2audiobook, including display libraries, Calibre, ffmpeg, mediainfo, nodejs, espeak-ng, sox, Tesseract OCR, and mecab for Japanese text analysis. ```bash apt-get update -qq ``` ```bash apt-get install -y -qq libxcb-cursor0 libegl1 libopengl0 ``` ```bash sudo -v && wget -nv -O- https://download.calibre-ebook.com/linux-installer.sh | sudo sh /dev/stdin ``` ```bash apt-get install -y -qq ffmpeg ``` ```bash apt-get install -y -qq mediainfo ``` ```bash apt-get install -y -qq nodejs ``` ```bash apt-get install -y -qq espeak-ng ``` ```bash apt-get install -y -qq sox ``` ```bash apt-get install -y -qq tesseract-ocr tesseract-ocr-eng ``` ```bash apt-get install -y -qq mecab libmecab-dev mecab-ipadic-utf8 ``` -------------------------------- ### Clone the ebook2audiobook Repository Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/README.md Use this command to download the project files to your local machine. Navigate into the cloned directory to proceed with installation. ```bash git clone https://github.com/DrewThomasson/ebook2audiobook.git cd ebook2audiobook ``` -------------------------------- ### Headless CLI - Process EPUB Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/tools/E2A-SML/README.md Analyze an EPUB file and generate SML output. Requires Calibre to be installed. ```bash # Process an epub (requires Calibre) python cli.py mybook.epub ``` -------------------------------- ### Run Web GUI Locally Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/tools/E2A-SML/README.md Start the SML Book Dialog Extractor's web-based graphical user interface. ```bash python cli.py --gui ``` -------------------------------- ### Get Help Command for Docker Container Parameters Source: https://github.com/drewthomasson/ebook2audiobook/wiki/Manual-Docker-Guide Retrieves the help information for all available parameters of the ebook2audiobook Docker container. ```bash docker run --pull always --rm athomasson2/ebook2audiobook:cpu --help ``` -------------------------------- ### Show Help on Windows Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/README.md Execute this command on Windows to view the help message and all configurable parameters. ```bash ebook2audiobook.cmd --help ``` -------------------------------- ### Python Package Setup Script Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/ext/py/num2words/num2words.egg-info/SOURCES.txt This script is used for packaging and distributing the num2words Python library. It defines metadata and dependencies required for installation. ```python from setuptools import setup, find_packages setup( name='num2words', version='0.5.10', packages=find_packages(), scripts=['bin/num2words'], description='Converts numbers to words in various languages.', long_description='Converts numbers to words in various languages.', author='Drew Thomasson', author_email='drew.thomasson@gmail.com', url='https://github.com/drewthomasson/ebook2audiobook', license='MIT', install_requires=[ 'pyyaml' ], classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', 'Topic :: Software Development :: Libraries :: Python Modules', ], keywords='numbers words language conversion', zip_safe=False ) ``` -------------------------------- ### Quick Start with Docker Compose Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/tools/E2A-SML/README.md Build and run the SML Book Dialog Extractor using Docker Compose. Access the web GUI at http://localhost:7860. ```bash docker compose up --build ``` -------------------------------- ### Initialize ebook2audiobook Environment Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/Notebooks/kaggle-ebook2audiobook.ipynb Sets up environment variables and defines helper functions for running commands, logging progress, and handling errors within the ebook2audiobook Kaggle notebook. This includes setting cache directories and defining logging utilities. ```python # @title 🚀 Run ebook2audiobook! import os import subprocess import time import shutil import sysconfig # Emojis for logs CHECK_MARK = "✅" CROSS_MARK = "❌" # Kaggle working directory SCRIPT_DIR = "/kaggle/working/ebook2audiobook" # ── Environment variables (mirrors the bash script) ────────────────────────── os.environ["PYTHONUTF8"] = "1" os.environ["PYTHONIOENCODING"] = "utf-8" os.environ["TTS_CACHE"] = f"{SCRIPT_DIR}/models" os.environ["TESSDATA_PREFIX"] = f"{SCRIPT_DIR}/models/tessdata" os.environ["TMPDIR"] = f"{SCRIPT_DIR}/tmp" def display_loading_bar(total_steps): print("\n--- LOADING... Total steps:", total_steps, " ---") def update_progress(step, total_steps): bar_length = 20 progress_percent = int((step / total_steps) * 100) progress_filled = int(bar_length * step / total_steps) bar = '=' * progress_filled + '>' + ' ' * max(bar_length - progress_filled - 1, 0) print(f"--- PROGRESS: [{bar}] {progress_percent}% ({step}/{total_steps}) ---") def run_command_with_log(command, description, step_progress, total_step_commands): """Runs a shell command and logs progress, outcome and duration.""" print(f"\n{step_progress}/{total_step_commands}: {description}...") start_time = time.time() try: process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = process.communicate() duration = f"{time.time() - start_time:.2f}" if process.returncode != 0: print(f"{CROSS_MARK} Command failed: {description} (Took {duration}s)") print(f" Command: {command}") print(f" Error Output:\n{stderr.decode()}") return False else: update_progress(step_progress, total_step_commands) print(f"{CHECK_MARK} {step_progress}/{total_step_commands} completed: {description} (Took {duration}s)") return True except Exception as e: duration = f"{time.time() - start_time:.2f}" print(f"{CROSS_MARK} Error during: {description} (Took {duration}s) — {e}") return False # ── Step 1 : OS-level packages ──────────────────────────────────────────────── ``` -------------------------------- ### Install num2words using pip Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/ext/py/num2words/README.rst Use pip to install the num2words library. This is the recommended method for installation. ```bash pip install num2words ``` -------------------------------- ### Install Demucs Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/ext/py/demucs/Demucs.ipynb Install the Demucs library using pip. For local development, use the editable install option. ```python !pip install -U demucs # or for local development, if you have a clone of Demucs # pip install -e . ``` -------------------------------- ### Show Help on Linux/MacOS Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/README.md Run this command on Linux or MacOS to display the help message and a list of all available parameters. ```bash ./ebook2audiobook.command --help ``` -------------------------------- ### Show Help for All OS Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/README.md Use this command to display the help message and parameters, compatible across all operating systems. ```python app.py --help ``` -------------------------------- ### Install Rust for Python Package Dependencies Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/Notebooks/colab_ebook2audiobook.ipynb Installs Rust using the official installer script. It ensures Rust is added to the PATH for the current session by sourcing the cargo environment file. ```bash curl -fsSL https://sh.rustup.rs | sh -s -- -y --quiet && \ echo 'source $HOME/.cargo/env' >> ~/.bashrc ``` -------------------------------- ### Run XTTS Finetune WebUI Interface Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/Notebooks/finetune/xtts/kaggle-xtts-finetune-webui-gradio-gui.ipynb Clones the xtts-finetune-webui repository and launches the Gradio interface. This command changes the directory to /tmp/, clones the repo, navigates into it, and starts the Python script with a public share link. ```bash # @title 🚀 Run interface %cd /tmp/ !git clone https://github.com/Rihcus/xtts-finetune-webui #float16 is swapped to float32 %cd /tmp/xtts-finetune-webui !python xtts_demo.py --share ``` -------------------------------- ### Create Input and Output Directories for Headless Docker Source: https://github.com/drewthomasson/ebook2audiobook/wiki/Manual-Docker-Guide Sets up the necessary directories for input files and audiobook output when running the Docker container in headless mode. ```bash mkdir input-folder && mkdir Audiobooks ``` -------------------------------- ### Check CUDA Version and Install cuDNN Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/Notebooks/finetune/xtts/kaggle-xtts-finetune-webui-gradio-gui.ipynb Verifies the installed NVIDIA CUDA toolkit version and installs a specific version of cuDNN to resolve potential dependency issues. This is crucial for GPU acceleration. ```bash !nvcc --version !apt-get install libcudnn9-cuda-12 9.1.0 #fix a dependency issue ``` -------------------------------- ### Install System Packages and Python 3.11 Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/Notebooks/kaggle-ebook2audiobook.ipynb Installs necessary system packages and Python 3.11 on a Debian-based system. This includes updating package lists, adding a PPA for newer Python versions, and installing Python 3.11 with essential modules. ```bash # Update system packages !sudo apt-get update -y # Install prerequisites !sudo apt-get install -y software-properties-common # Add deadsnakes PPA for newer Python versions !sudo add-apt-repository -y ppa:deadsnakes/ppa !sudo apt-get update -y # Install Python 3.11 and essentials !sudo apt-get install -y python3.11 python3.11-distutils python3.11-venv # Install pip for Python 3.11 !wget -q https://bootstrap.pypa.io/get-pip.py !python3.11 get-pip.py # Register Python 3.11 as an alternative !sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 !sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2 # Automatically set Python 3.11 as default (no prompt) !sudo update-alternatives --set python3 /usr/bin/python3.11 # Verify Python version !python3 --version # Upgrade pip !python3 -m pip install --upgrade pip ``` -------------------------------- ### Docker CLI - Run Web GUI Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/tools/E2A-SML/README.md Run the SML extractor Docker image and expose the web GUI. Mount your ebook2audiobook folder to the container. ```bash # Build the image docker build -t sml-extractor . # Run the web GUI (mount your ebook2audiobook folder) docker run -p 7860:7860 -v $(pwd)/../..:/ebook2audiobook sml-extractor ``` -------------------------------- ### BookNLP Format Example Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/tools/E2A-SML/README.md Example of the raw output format from BookNLP, showing narrator and character dialog attribution. ```text [Narrator] It was a bright cold day in April, and the clocks were striking thirteen. [/] [Winston] "Freedom is the freedom to say that two plus two make four." [/] [OBrien] "How many fingers am I holding up, Winston?" [/] ``` -------------------------------- ### Run XTTS Finetune WebUI Interface Source: https://github.com/drewthomasson/ebook2audiobook/blob/main/Notebooks/finetune/xtts/colab_xtts_finetune_webui.ipynb Clones the XTTS finetune web UI repository and launches the Gradio interface. This command assumes you are in the correct directory and have the necessary dependencies installed. ```bash # @title 🚀 Run interface %cd /content/ !git clone https://github.com/DrewThomasson/xtts-finetune-webui.git %cd /content/xtts-finetune-webui !python xtts_demo.py --share ```