From 0db7b73678b8eafa60c49cccb549223db51a1a4b Mon Sep 17 00:00:00 2001 From: jteijema Date: Tue, 14 Jan 2025 16:14:44 +0100 Subject: [PATCH 1/4] Flexible UI port --- docker/cpu/docker-compose.yml | 2 ++ ui/Dockerfile | 3 +++ ui/lib/config.py | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/cpu/docker-compose.yml b/docker/cpu/docker-compose.yml index 6e89c76..a545122 100644 --- a/docker/cpu/docker-compose.yml +++ b/docker/cpu/docker-compose.yml @@ -35,3 +35,5 @@ services: - GRADIO_WATCH=True # Enable hot reloading - PYTHONUNBUFFERED=1 # Ensure Python output is not buffered - DISABLE_LOCAL_SAVING=false # Set to 'true' to disable local saving and hide file view + - API_HOST=kokoro-tts # Set TTS service URL + - API_PORT=8880 # Set TTS service PORT diff --git a/ui/Dockerfile b/ui/Dockerfile index 0266b19..e1726fb 100644 --- a/ui/Dockerfile +++ b/ui/Dockerfile @@ -11,5 +11,8 @@ RUN mkdir -p data/inputs data/outputs # Copy the application files COPY . . +ENV API_HOST=kokoro-tts +ENV API_PORT=8880 + # Run the Gradio app CMD ["python", "app.py"] diff --git a/ui/lib/config.py b/ui/lib/config.py index 2a4aeb7..406cdf0 100644 --- a/ui/lib/config.py +++ b/ui/lib/config.py @@ -1,7 +1,9 @@ import os # API Configuration -API_URL = "http://kokoro-tts:8880" +API_HOST = os.getenv("API_HOST", "kokoro-tts") +API_PORT = os.getenv("API_PORT", "8880") +API_URL = f"http://{API_HOST}:{API_PORT}" # File paths INPUTS_DIR = "/app/ui/data/inputs" From a1e01dbdbed6e019f048e0d63f9f2c39b3262942 Mon Sep 17 00:00:00 2001 From: jteijema Date: Tue, 14 Jan 2025 16:30:06 +0100 Subject: [PATCH 2/4] Update the readme --- README.md | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1f9d637..cac2131 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ Dockerized FastAPI wrapper for [Kokoro-82M](https://huggingface.co/hexgrad/Kokor The service can be accessed through either the API endpoints or the Gradio web interface. 1. Install prerequisites: - - Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) - - Clone the repository: + - Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) + - Clone the repository: ```bash git clone https://github.com/remsky/Kokoro-FastAPI.git cd Kokoro-FastAPI @@ -33,22 +33,40 @@ The service can be accessed through either the API endpoints or the Gradio web i 2. Start the service: - - Using Docker Compose (Full setup including UI): + - Using Docker Compose (Full setup including UI): ```bash cd docker/gpu # OR # cd docker/cpu # Run this or the above docker compose up --build ``` - - OR running the API alone using Docker (model + voice packs baked in): - ```bash + Once started: + - The API will be available at http://localhost:8880 + - The UI can be accessed at http://localhost:7860 + - OR run the API alone using Docker (model + voice packs baked in): + ```bash docker run -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest # CPU docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:latest # Nvidia GPU + # Minified versions are available with `:latest-slim` tag, though it is a first test and may not be functional ``` + +3. Running the UI Docker Service: + + - If you only want to run the Gradio web interface separately and connect it to an existing API service: + ```bash + docker run -p 7860:7860 \ + -e API_HOST= \ + -e API_PORT=8880 \ + ghcr.io/remsky/kokoro-fastapi-ui:v0.1.0 + ``` + + - Replace `` with: + - `kokoro-tts` if the UI container is running in the same Docker Compose setup. + - `localhost` if the API is running on your local machine. -2. Run locally as an OpenAI-Compatible Speech Endpoint +4. Run locally as an OpenAI-Compatible Speech Endpoint ```python from openai import OpenAI client = OpenAI( From 55ea0db7df0880e7fa791cd86d52aefb619b89e0 Mon Sep 17 00:00:00 2001 From: jteijema Date: Tue, 14 Jan 2025 16:36:55 +0100 Subject: [PATCH 3/4] Update GPU compose --- docker/gpu/docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker/gpu/docker-compose.yml b/docker/gpu/docker-compose.yml index 9989e18..7cb4b94 100644 --- a/docker/gpu/docker-compose.yml +++ b/docker/gpu/docker-compose.yml @@ -35,3 +35,5 @@ services: - GRADIO_WATCH=1 # Enable hot reloading - PYTHONUNBUFFERED=1 # Ensure Python output is not buffered - DISABLE_LOCAL_SAVING=false # Set to 'true' to disable local saving and hide file view + - API_HOST=kokoro-tts # Set TTS service URL + - API_PORT=8880 # Set TTS service PORT From aefd525c89903b34c91cb48289581961ecc248f6 Mon Sep 17 00:00:00 2001 From: jteijema Date: Tue, 14 Jan 2025 16:39:17 +0100 Subject: [PATCH 4/4] Update spacing in the readme --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cac2131..6564de0 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ Dockerized FastAPI wrapper for [Kokoro-82M](https://huggingface.co/hexgrad/Kokor The service can be accessed through either the API endpoints or the Gradio web interface. 1. Install prerequisites: - - Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) - - Clone the repository: + - Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) + - Clone the repository: ```bash git clone https://github.com/remsky/Kokoro-FastAPI.git cd Kokoro-FastAPI @@ -33,17 +33,17 @@ The service can be accessed through either the API endpoints or the Gradio web i 2. Start the service: - - Using Docker Compose (Full setup including UI): + - Using Docker Compose (Full setup including UI): ```bash cd docker/gpu # OR # cd docker/cpu # Run this or the above docker compose up --build ``` Once started: - - The API will be available at http://localhost:8880 - - The UI can be accessed at http://localhost:7860 + - The API will be available at http://localhost:8880 + - The UI can be accessed at http://localhost:7860 - - OR run the API alone using Docker (model + voice packs baked in): + - OR run the API alone using Docker (model + voice packs baked in): ```bash docker run -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest # CPU docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:latest # Nvidia GPU @@ -53,7 +53,7 @@ The service can be accessed through either the API endpoints or the Gradio web i 3. Running the UI Docker Service: - - If you only want to run the Gradio web interface separately and connect it to an existing API service: + - If you only want to run the Gradio web interface separately and connect it to an existing API service: ```bash docker run -p 7860:7860 \ -e API_HOST= \ @@ -61,9 +61,9 @@ The service can be accessed through either the API endpoints or the Gradio web i ghcr.io/remsky/kokoro-fastapi-ui:v0.1.0 ``` - - Replace `` with: - - `kokoro-tts` if the UI container is running in the same Docker Compose setup. - - `localhost` if the API is running on your local machine. + - Replace `` with: + - `kokoro-tts` if the UI container is running in the same Docker Compose setup. + - `localhost` if the API is running on your local machine. 4. Run locally as an OpenAI-Compatible Speech Endpoint