From a1745ade82faf68f65d1cac1b5629653943dcefd Mon Sep 17 00:00:00 2001 From: Allen Nikka Date: Wed, 13 Nov 2024 17:38:24 -0800 Subject: [PATCH] Minor updates to piper voice, ingnoring env files, and updating the example docker compose file Remove unused import --- .gitignore | 3 ++ Dockerfile | 2 +- .../piper_docker_tts_provider.py | 7 +-- docker-compose.piper-example.yml | 42 ++++++++++++++++ docker-compose.yml | 48 ------------------- requirements.txt | 5 -- 6 files changed, 47 insertions(+), 60 deletions(-) create mode 100644 docker-compose.piper-example.yml delete mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 7bbd194..ef231d9 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,6 @@ scripts/ # Models piper_models/* + +# Env files +.env diff --git a/Dockerfile b/Dockerfile index 897ca2e..e372ce6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,4 +17,4 @@ RUN pip install --no-cache-dir -r requirements.txt WORKDIR /app # Set this as the default command -ENTRYPOINT [ "python", "/app_src/main.py" ] \ No newline at end of file +# ENTRYPOINT [ "python", "/app_src/main.py" ] \ No newline at end of file diff --git a/audiobook_generator/tts_providers/piper_docker_tts_provider.py b/audiobook_generator/tts_providers/piper_docker_tts_provider.py index 7d71c01..c55f0a6 100644 --- a/audiobook_generator/tts_providers/piper_docker_tts_provider.py +++ b/audiobook_generator/tts_providers/piper_docker_tts_provider.py @@ -1,4 +1,3 @@ -from math import e import os import asyncio import logging @@ -128,14 +127,10 @@ async def chunkify(self) -> AudioSegment: ) estimated_remaining_time_m = total_seconds_remaining // 60 estimated_remaining_time_s = total_seconds_remaining % 60 - print( + logger.info( f"Processed {len(results)} of {len(tasks)} chunks in chapter. Estimated time remaining for chapter: {round(estimated_remaining_time_m)} min, {round(estimated_remaining_time_s)} sec", - end="\r", - flush=True, ) - # results = await asyncio.gather(*tasks, return_exceptions=True) - audio_segments = [] # Collect results and reconstruct the audio segments in order results_dict = {} diff --git a/docker-compose.piper-example.yml b/docker-compose.piper-example.yml new file mode 100644 index 0000000..4047056 --- /dev/null +++ b/docker-compose.piper-example.yml @@ -0,0 +1,42 @@ +services: + piper: + image: lscr.io/linuxserver/piper:latest + container_name: piper + environment: + - PUID=1000 + - PGID=1000 + - TZ=Etc/UTC + - PIPER_VOICE=en_US-hfc_male-medium + - PIPER_LENGTH=1.0 # optional + - PIPER_NOISE=0.667 # optional + - PIPER_NOISEW=0.333 # optional + - PIPER_SPEAKER=0 # optional + - PIPER_PROCS=1 # optional + volumes: + # - /path/to/piper/data:/config # Optional volume for Piper config + - ./piper_models:/usr/share/piper_models # Volume for Piper models, find models at https://github.com/rhasspy/piper/ + ports: + - 10200:10200 + restart: unless-stopped + healthcheck: + test: ['CMD-SHELL', 'nc -z localhost 10200'] + interval: 10s + timeout: 5s + retries: 5 + + epub_to_audiobook: + build: + context: ./ # Directory containing the Dockerfile for epub_to_audiobook + dockerfile: Dockerfile # Name of the Dockerfile (if it's not the default 'Dockerfile') + container_name: epub_to_audiobook + environment: + - PIPER_HOST=piper + - PIPER_PORT=10200 + volumes: + - ./:/app + - :/epub_src # Map the top level epub directory on the host machine + # command: tail -f /dev/null # Uncomment this line to keep the container running, and run via connecting to it with `docker exec -it epub_to_audiobook /bin/bash` + command: "python main.py --tts piper_docker --no_prompt '/epub_src/' audiobook_output" # Run command directly when the containers start up + depends_on: + piper: + condition: service_healthy diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 75d985a..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,48 +0,0 @@ -# Be sure to replace and with your actual -# Azure Text-to-Speech API credentials. Also, replace your_book.epub with the -# name of your EPUB file, and audiobook_output with the name of the directory -# where you want to save the output files. - -# After creating and saving the `docker-compose.yml` file, run the -# `docker-compose up` command in the same directory to pull the image and start -# the conversion process. - -# You can then try to modify volumes to fit your need. - -services: - piper: - image: lscr.io/linuxserver/piper:latest - container_name: piper - environment: - - PUID=1000 - - PGID=1000 - - TZ=Etc/UTC - - PIPER_VOICE=en_US-norman-medium - - PIPER_LENGTH=1.0 # optional - - PIPER_NOISE=0.667 # optional - - PIPER_NOISEW=0.333 # optional - - PIPER_SPEAKER=0 # optional - - PIPER_PROCS=1 # optional - volumes: - # - /path/to/piper/data:/config - - /Users/allennikka/Developer/epub_to_audiobook/piper_models:/usr/share/piper_models # Volume for Piper models - ports: - - 10200:10200 - restart: unless-stopped - - epub_to_audiobook: - build: - context: ./ # Directory containing the Dockerfile for epub_to_audiobook - dockerfile: Dockerfile # Name of the Dockerfile (if it's not the default 'Dockerfile') - container_name: epub_to_audiobook - environment: - - TTS_PROVIDER=piper_docker - - PIPER_HOST=piper - - PIPER_PORT=10200 - volumes: - - ./:/app - - /Users/allennikka/Calibre Library:/calibre_library # Map the Calibre Library directory - - command: "--tts piper_docker --no_prompt '/calibre_library/Erick Ries/The Lean Startup Erick Ries (15)/The Lean Startup Erick Ries - Erick Ries.epub' audiobook_output --chapter_start 1 --chapter_end 2" - depends_on: - - piper diff --git a/requirements.txt b/requirements.txt index 2ca822b..8165165 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,10 +5,5 @@ openai==1.35.7 requests==2.32.3 socksio==1.0.0 edge-tts==6.1.12 -<<<<<<< HEAD pydub==0.25.1 -======= -pydub==0.25.1 -python-dotenv==1.0.1 wyoming==1.6.0 ->>>>>>> 4679f9c (Init commit of local piper docker compose container)