Merge branch 'master' into update-UI-access

This commit is contained in:
remsky 2025-01-15 20:44:54 -07:00 committed by GitHub
commit 746fd9be4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 36 additions and 53 deletions

15
.gitignore vendored
View file

@ -34,23 +34,10 @@ ENV/
# Project specific # Project specific
# Model files # Model files
*.pt
*.pth *.pth
*.tar* *.tar*
# Voice files
api/src/voices/af_bella.pt
api/src/voices/af_nicole.pt
api/src/voices/af_sarah.pt
api/src/voices/af_sky.pt
api/src/voices/af.pt
api/src/voices/am_adam.pt
api/src/voices/am_michael.pt
api/src/voices/bf_emma.pt
api/src/voices/bf_isabella.pt
api/src/voices/bm_george.pt
api/src/voices/bm_lewis.pt
# Audio files # Audio files
examples/*.wav examples/*.wav
examples/*.pcm examples/*.pcm

View file

@ -23,47 +23,31 @@ 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. The service can be accessed through either the API endpoints or the Gradio web interface.
1. Install prerequisites: 1. Install prerequisites, and start the service using Docker Compose (Full setup including UI):
- Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) - Install [Docker Desktop](https://www.docker.com/products/docker-desktop/)
- Clone the repository: - Clone the repository:
```bash ```bash
git clone https://github.com/remsky/Kokoro-FastAPI.git git clone https://github.com/remsky/Kokoro-FastAPI.git
cd Kokoro-FastAPI cd Kokoro-FastAPI
```
# * Switch to stable branch if any issues *
git checkout v0.0.5post1-stable
2. Start the service:
- Using Docker Compose (Full setup including UI):
```bash
cd docker/gpu # OR cd docker/gpu # OR
# cd docker/cpu # Run this or the above # cd docker/cpu # Run this or the above
docker compose up --build docker compose up --build
``` ```
Once started: Once started:
- The API will be available at http://localhost:8880 - The API will be available at http://localhost:8880
- The UI can be accessed at http://localhost:7860 - 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 __Or__ running the API alone using Docker (model + voice packs baked in) (Most Recent):
```
```bash
3. Running the UI Docker Service: docker run -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:v0.1.0post1 # CPU
docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:v0.1.0post1 # Nvidia GPU
- 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=<api-hostname-or-ip> \
-e API_PORT=8880 \
ghcr.io/remsky/kokoro-fastapi-ui:v0.1.0
```
- Replace `<api-hostname-or-ip>` 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 4. Run locally as an OpenAI-Compatible Speech Endpoint
@ -74,13 +58,14 @@ The service can be accessed through either the API endpoints or the Gradio web i
api_key="not-needed" api_key="not-needed"
) )
response = client.audio.speech.create( with client.audio.speech.with_streaming_response.create(
model="kokoro", model="kokoro",
voice="af_sky+af_bella", #single or multiple voicepack combo voice="af_sky+af_bella", #single or multiple voicepack combo
input="Hello world!", input="Hello world!",
response_format="mp3" response_format="mp3"
) ) as response:
response.stream_to_file("output.mp3") response.stream_to_file("output.mp3")
``` ```
or visit http://localhost:7860 or visit http://localhost:7860
@ -200,8 +185,19 @@ If you only want the API, just comment out everything in the docker-compose.yml
Currently, voices created via the API are accessible here, but voice combination/creation has not yet been added Currently, voices created via the API are accessible here, but voice combination/creation has not yet been added
*Note: Recent updates for streaming could lead to temporary glitches. If so, pull from the most recent stable release v0.0.2 to restore* 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=<api-hostname-or-ip> \
-e API_PORT=8880 \
ghcr.io/remsky/kokoro-fastapi-ui:v0.1.0
```
- Replace `<api-hostname-or-ip>` 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.
### Disabling Local Saving ### Disabling Local Saving
You can disable local saving of audio files and hide the file view in the UI by setting the `DISABLE_LOCAL_SAVING` environment variable to `true`. This is useful when running the service on a server where you don't want to store generated audio files locally. You can disable local saving of audio files and hide the file view in the UI by setting the `DISABLE_LOCAL_SAVING` environment variable to `true`. This is useful when running the service on a server where you don't want to store generated audio files locally.

BIN
api/src/voices/af.pt Normal file

Binary file not shown.

BIN
api/src/voices/af_bella.pt Normal file

Binary file not shown.

BIN
api/src/voices/af_nicole.pt Normal file

Binary file not shown.

BIN
api/src/voices/af_sarah.pt Normal file

Binary file not shown.

BIN
api/src/voices/af_sky.pt Normal file

Binary file not shown.

BIN
api/src/voices/am_adam.pt Normal file

Binary file not shown.

Binary file not shown.

BIN
api/src/voices/bf_emma.pt Normal file

Binary file not shown.

Binary file not shown.

BIN
api/src/voices/bm_george.pt Normal file

Binary file not shown.

BIN
api/src/voices/bm_lewis.pt Normal file

Binary file not shown.

View file

@ -1,10 +1,10 @@
name: kokoro-tts name: kokoro-tts
services: services:
kokoro-tts: kokoro-tts:
image: ghcr.io/remsky/kokoro-fastapi-cpu:v0.1.0 # image: ghcr.io/remsky/kokoro-fastapi-cpu:v0.1.0
# build: build:
# context: ../.. context: ../..
# dockerfile: docker/cpu/Dockerfile dockerfile: docker/cpu/Dockerfile
volumes: volumes:
- ../../api/src:/app/api/src - ../../api/src:/app/api/src
- ../../api/src/voices:/app/api/src/voices - ../../api/src/voices:/app/api/src/voices

View file

@ -1,10 +1,10 @@
name: kokoro-tts name: kokoro-tts
services: services:
kokoro-tts: kokoro-tts:
image: ghcr.io/remsky/kokoro-fastapi-gpu:v0.1.0 # image: ghcr.io/remsky/kokoro-fastapi-gpu:v0.1.0
# build: build:
# context: ../.. context: ../..
# dockerfile: docker/gpu/Dockerfile dockerfile: docker/gpu/Dockerfile
volumes: volumes:
- ../../api/src:/app/api/src # Mount src for development - ../../api/src:/app/api/src # Mount src for development
- ../../api/src/voices:/app/api/src/voices # Mount voices for persistence - ../../api/src/voices:/app/api/src/voices # Mount voices for persistence