### Start WebUI with Default Host and Port Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Launch the WebUI using the provided Python script. The interface will be accessible at http://127.0.0.1:7860 by default. ```bash python3 main_ui.py ``` -------------------------------- ### Run Kokoro TTS with CPU via Docker Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Starts a Docker container for Kokoro TTS using CPU for processing. Ensure Docker is installed and running. ```bash docker run -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu ``` -------------------------------- ### Start WebUI with Custom Host and Port Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Customize the host and port when starting the WebUI. This allows you to specify a different network address or port number for accessibility. ```bash python3 main_ui.py --host 127.0.0.1 --port 8080 ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Install the required Python packages listed in the requirements.txt file. Note potential version conflicts with older Python installations. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install ffmpeg on Ubuntu Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Installs the ffmpeg binary on Ubuntu systems to resolve 'FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg''. ```bash sudo apt install ffmpeg ``` -------------------------------- ### Install ffmpeg on macOS using Homebrew Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Installs the ffmpeg binary on macOS systems using Homebrew to resolve 'FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg''. ```bash brew install ffmpeg ``` -------------------------------- ### Run Kokoro TTS with GPU via Docker Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Starts a Docker container for Kokoro TTS utilizing GPU acceleration. Requires Docker with GPU support. ```bash docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu ``` -------------------------------- ### Install importlib-metadata for older Python versions Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Installs the 'importlib-metadata' package to resolve 'ModuleNotFoundError' on Python versions older than 3.8. ```bash pip3 install importlib-metadata ``` -------------------------------- ### Pull Docker Image Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Download the latest Docker image for the epub_to_audiobook tool from the GitHub Container Registry. Ensure Docker is installed before running this command. ```bash docker pull ghcr.io/p0n1/epub_to_audiobook:latest ``` -------------------------------- ### Run WebUI using Docker Compose Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Deploy the WebUI using Docker Compose for an easier setup. Ensure you edit the 'docker-compose.webui.yml' file to include your API keys. ```bash # Edit docker-compose.webui.yml with your API keys docker compose -f docker-compose.webui.yml up ``` -------------------------------- ### Preview EPUB Chapter Summary Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Use the --preview option to get a summary of each chapter's character count without converting to speech. This is useful for initial analysis of the EPUB file. ```bash python3 main.py examples/The_Life_and_Adventures_of_Robinson_Crusoe.epub output_folder --preview ``` -------------------------------- ### Run EPUB to Audiobook Conversion with Piper TTS via Docker Compose Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Initiates the EPUB to audiobook conversion process using Piper TTS within a Docker container setup. This requires Docker Desktop, a downloaded Piper model, and configuration of the docker-compose.piper-example.yml file. ```sh PATH_TO_EPUB_FILE=./Your_epub_file.epub OUTPUT_DIR=$(pwd)/path/to/audiobook_output docker compose -f docker-compose.piper-example.yml up --build ``` -------------------------------- ### Set Environment Variables for TTS Providers Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Configure environment variables for Azure TTS or OpenAI TTS before starting the WebUI. Replace placeholders with your actual API keys and region. ```bash export MS_TTS_KEY= # For Azure TTS export MS_TTS_REGION= # For Azure TTS export OPENAI_API_KEY= # For OpenAI TTS export OPENAI_BASE_URL= # Optional: For custom OpenAI-compatible endpoints ``` -------------------------------- ### Basic EPUB to Audiobook Conversion with Piper TTS Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Converts an EPUB file to an audiobook using Piper TTS with minimal parameters. Ensure Piper TTS is installed and the onnx model file is specified. The 'piper' executable should be in your system's PATH. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts piper --model_name /en_US-libritts_r-medium.onnx ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Clone the project repository and change the directory to the project's root. ```bash git clone https://github.com/p0n1/epub_to_audiobook.git cd epub_to_audiobook ``` -------------------------------- ### Display Help and Options Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Execute the script with the `-h` flag to view all available command-line options and their descriptions. This is useful for understanding the script's full capabilities and configuration. ```bash python3 main.py -h ``` -------------------------------- ### Use OpenAI-Compatible Service with Custom URL and Voice Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Run an EPUB to audiobook conversion using an OpenAI-compatible service by setting the OPENAI_BASE_URL environment variable. An API key is still required but can be nonsensical. ```shell docker run -i -t --rm -v ./:/app -e OPENAI_BASE_URL=http://127.0.0.1:8000/v1 -e OPENAI_API_KEY=nope ghcr.io/p0n1/epub_to_audiobook your_book.epub audiobook_output --tts openai --voice_name=skippy --model_name=tts-1-hd ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Create a Python virtual environment and activate it for managing project dependencies. ```bash python3 -m venv venv source venv/bin/activate ``` -------------------------------- ### Configure Environment and Run Script with Kokoro TTS Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Sets environment variables for OpenAI compatibility and executes the main script with Kokoro TTS. Requires the script to be in the current directory. ```bash export OPENAI_BASE_URL=http://localhost:8880/v1 export OPENAI_API_KEY="fake" python main.py path/to/epub output-dir --tts openai --voice_name "af_bella(3)+af_alloy(1)" --model_name "tts-1" ``` -------------------------------- ### Full Script Options Help Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md This is the detailed output of the `python3 main.py -h` command, listing all available arguments and their explanations. It covers TTS provider selection, logging levels, preview mode, language settings, newline modes, title parsing strategies, chapter range selection, outputting text files, removing endnotes, and search/replace functionality. ```bash usage: main.py [-h] [--tts {azure,openai,edge,piper}] [--log {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [--preview] [--no_prompt] [--language LANGUAGE] [--newline_mode {single,double,none}] [--title_mode {auto,tag_text,first_few}] [--chapter_start CHAPTER_START] [--chapter_end CHAPTER_END] [--output_text] [--remove_endnotes] [--search_and_replace_file SEARCH_AND_REPLACE_FILE] [--worker_count WORKER_COUNT] [--voice_name VOICE_NAME] [--output_format OUTPUT_FORMAT] [--model_name MODEL_NAME] [--voice_rate VOICE_RATE] [--voice_volume VOICE_VOLUME] [--voice_pitch VOICE_PITCH] [--proxy PROXY] [--break_duration BREAK_DURATION] [--piper_path PIPER_PATH] [--piper_speaker PIPER_SPEAKER] [--piper_sentence_silence PIPER_SENTENCE_SILENCE] [--piper_length_scale PIPER_LENGTH_SCALE] input_file output_folder Convert text book to audiobook positional arguments: input_file Path to the EPUB file output_folder Path to the output folder options: -h, --help show this help message and exit --tts {azure,openai,edge,piper} Choose TTS provider (default: azure). azure: Azure Cognitive Services, openai: OpenAI TTS API. When using azure, environment variables MS_TTS_KEY and MS_TTS_REGION must be set. When using openai, environment variable OPENAI_API_KEY must be set. --log {DEBUG,INFO,WARNING,ERROR,CRITICAL} Log level (default: INFO), can be DEBUG, INFO, WARNING, ERROR, CRITICAL --preview Enable preview mode. In preview mode, the script will not convert the text to speech. Instead, it will print the chapter index, titles, and character counts. --no_prompt Don't ask the user if they wish to continue after estimating the cloud cost for TTS. Useful for scripting. --language LANGUAGE Language for the text-to-speech service (default: en- US). For Azure TTS (--tts=azure), check https://learn.microsoft.com/en-us/azure/ services/speech-service/language- support?tabs=tts#text-to-speech for supported languages. For OpenAI TTS (--tts=openai), their API detects the language automatically. But setting this will also help on splitting the text into chunks with different strategies in this tool, especially for Chinese characters. For Chinese books, use zh-CN, zh- TW, or zh-HK. --newline_mode {single,double,none} Choose the mode of detecting new paragraphs: 'single', 'double', or 'none'. 'single' means a single newline character, while 'double' means two consecutive newline characters. 'none' means all newline characters will be replace with blank so paragraphs will not be detected. (default: double, works for most ebooks but will detect less paragraphs for some ebooks) --title_mode {auto,tag_text,first_few} Choose the parse mode for chapter title, 'tag_text' search 'title','h1','h2','h3' tag for title, 'first_few' set first 60 characters as title, 'auto' auto apply the best mode for current chapter. --chapter_start CHAPTER_START Chapter start index (default: 1, starting from 1) --chapter_end CHAPTER_END Chapter end index (default: -1, meaning to the last chapter) --output_text Enable Output Text. This will export a plain text file for each chapter specified and write the files to the output folder specified. --remove_endnotes This will remove endnote numbers from the end or middle of sentences. This is useful for academic books. --search_and_replace_file SEARCH_AND_REPLACE_FILE ``` -------------------------------- ### Convert EPUB to Audiobook Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Run the main script to convert an EPUB file to an audiobook. Specify the input EPUB file, the output folder, and optionally a TTS provider using the `--tts` flag. ```bash python3 main.py [options] ``` -------------------------------- ### Run Audiobook Generation with Kokoro TTS via Docker Compose Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Executes the audiobook generation process using Docker Compose with Kokoro TTS. Replace placeholder values with your specific file paths and desired voice name. ```bash PATH_TO_EPUB_FILE=./Your_epub_file.epub OUTPUT_DIR=$(pwd)/path/to/audiobook_output VOICE_NAME=Your_desired_voice docker compose -f docker-compose.kokoro-example.yml up --build ``` -------------------------------- ### Run Docker Container with OpenAI TTS Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Execute the epub_to_audiobook tool within a Docker container using OpenAI TTS. Mounts the current directory and sets the OpenAI API key environment variable. ```bash docker run -i -t --rm -v ./:/app -e OPENAI_API_KEY=$OPENAI_API_KEY ghcr.io/p0n1/epub_to_audiobook your_book.epub audiobook_output --tts openai ``` -------------------------------- ### OpenAI TTS with Preview and Text Output Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Enable preview mode and text output for OpenAI TTS, which displays chapter information and exports the text instead of audio. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts openai --preview --output_text ``` -------------------------------- ### Run Docker Container with Azure TTS Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Execute the epub_to_audiobook tool within a Docker container using Azure Text-to-Speech. Mounts the current directory and sets necessary environment variables for TTS. ```bash docker run -i -t --rm -v ./:/app -e MS_TTS_KEY=$MS_TTS_KEY -e MS_TTS_REGION=$MS_TTS_REGION ghcr.io/p0n1/epub_to_audiobook your_book.epub audiobook_output --tts azure ``` -------------------------------- ### Generate Audiobook from EPUB Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Execute the main script with the EPUB file path and an output directory. This command generates MP3 files for each chapter using default TTS settings. ```bash python3 main.py examples/The_Life_and_Adventures_of_Robinson_Crusoe.epub output_folder ``` -------------------------------- ### Convert EPUB with Search and Replace Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Convert an EPUB file to an audiobook using a specified search and replace configuration file. This allows for text normalization and pronunciation adjustments. ```bash python3 main.py examples/The_Life_and_Adventures_of_Robinson_Crusoe.epub output_folder --search_and_replace_file search.conf ``` -------------------------------- ### Search and Replace Configuration Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Define search and replace rules in a configuration file to modify text within the EPUB before conversion. Each line should contain a regex search and its replacement, separated by '=='. ```text # this is the general structure == # this is a comment # fix cardinal direction abbreviations N.E.==north east # be careful with your regexes, as this would also match Sally N. Smith N.==north # pronounce Barbadoes like the locals Barbadoes==Barbayduss ``` -------------------------------- ### Set Environment Variables for TTS APIs Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Configure necessary environment variables for Azure Text-to-Speech or OpenAI Text-to-Speech API credentials. ```bash export MS_TTS_KEY= # for Azure export MS_TTS_REGION= # for Azure export OPENAI_API_KEY= # for OpenAI ``` -------------------------------- ### Basic OpenAI TTS Conversion Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Perform a basic EPUB to audiobook conversion using OpenAI TTS with default settings. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts openai ``` -------------------------------- ### Basic Azure TTS Conversion Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Perform a basic EPUB to audiobook conversion using Azure TTS with default settings. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts azure ``` -------------------------------- ### Specify Custom Piper TTS Executable Path Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Converts an EPUB to an audiobook while specifying a custom path to the Piper TTS executable using the `--piper_path` parameter. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts piper --model_name /en_US-libritts_r-medium.onnx --piper_path /piper ``` -------------------------------- ### Specify Azure Voice and Language Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Use --voice_name and --language options to select a specific voice and language for Azure TTS. Consult Azure documentation for available options. ```bash python3 main.py --voice_name en-GB-LibbyNeural --language en-GB ``` -------------------------------- ### Azure TTS with Custom Language, Voice, and Logging Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Convert an EPUB to an audiobook using Azure TTS with a specified Chinese voice and language, and set the log level to DEBUG for detailed output. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts azure --language zh-CN --voice_name "zh-CN-YunyeNeural" --log DEBUG ``` -------------------------------- ### Basic Edge TTS Conversion Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Perform a basic EPUB to audiobook conversion using Edge TTS with default settings. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts edge ``` -------------------------------- ### OpenAI TTS with HD Model and Specific Voice Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Convert an EPUB to an audiobook using OpenAI TTS with the high-definition model and a specified voice. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts openai --model_name "tts-1-hd" --voice_name "fable" ``` -------------------------------- ### Specify Output Format for Piper TTS Audio Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Converts an EPUB to an audiobook using Piper TTS and specifies the output audio format (e.g., 'opus', 'mp3') using the `--output_format` parameter. Piper TTS defaults to 'wav' or raw format. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts piper --model_name /en_US-libritts_r-medium.onnx --piper_speaker 256 --piper_length_scale 1.5 --piper_sentence_silence 0.5 --output_format opus ``` -------------------------------- ### Edge TTS with Custom Language, Voice, and Logging Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Convert an EPUB to an audiobook using Edge TTS with a specified Chinese voice and language, and set the log level to DEBUG for detailed output. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts edge --language zh-CN --voice_name "zh-CN-YunxiNeural" --log DEBUG ``` -------------------------------- ### Select Piper TTS Voice with Voice Name Source: https://github.com/p0n1/epub_to_audiobook/blob/main/README.md Converts an EPUB to an audiobook and selects a specific voice from a Piper TTS model that supports multiple voices using the `--piper_speaker` parameter. ```sh python3 main.py "path/to/book.epub" "path/to/output/folder" --tts piper --model_name /en_US-libritts_r-medium.onnx --piper_speaker 256 ```