mirror of
https://github.com/remsky/Kokoro-FastAPI.git
synced 2025-04-13 09:39:17 +00:00
Merge branch 'master' into update-UI-access
This commit is contained in:
commit
746fd9be4b
15 changed files with 36 additions and 53 deletions
15
.gitignore
vendored
15
.gitignore
vendored
|
@ -34,23 +34,10 @@ ENV/
|
|||
|
||||
# Project specific
|
||||
# Model files
|
||||
*.pt
|
||||
|
||||
*.pth
|
||||
*.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
|
||||
examples/*.wav
|
||||
examples/*.pcm
|
||||
|
|
50
README.md
50
README.md
|
@ -23,48 +23,32 @@ 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:
|
||||
1. Install prerequisites, and start the service using Docker Compose (Full setup including UI):
|
||||
- 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
|
||||
```
|
||||
|
||||
2. Start the service:
|
||||
# * Switch to stable branch if any issues *
|
||||
git checkout v0.0.5post1-stable
|
||||
|
||||
- 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
|
||||
|
||||
- OR run the API alone using Docker (model + voice packs baked in):
|
||||
__Or__ running the API alone using Docker (model + voice packs baked in) (Most Recent):
|
||||
|
||||
```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
|
||||
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
|
||||
```
|
||||
|
||||
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=<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
|
||||
```python
|
||||
|
@ -74,13 +58,14 @@ The service can be accessed through either the API endpoints or the Gradio web i
|
|||
api_key="not-needed"
|
||||
)
|
||||
|
||||
response = client.audio.speech.create(
|
||||
with client.audio.speech.with_streaming_response.create(
|
||||
model="kokoro",
|
||||
voice="af_sky+af_bella", #single or multiple voicepack combo
|
||||
input="Hello world!",
|
||||
response_format="mp3"
|
||||
)
|
||||
) as response:
|
||||
response.stream_to_file("output.mp3")
|
||||
|
||||
```
|
||||
|
||||
or visit http://localhost:7860
|
||||
|
@ -200,7 +185,18 @@ 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
|
||||
|
||||
*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
|
||||
|
||||
|
|
BIN
api/src/voices/af.pt
Normal file
BIN
api/src/voices/af.pt
Normal file
Binary file not shown.
BIN
api/src/voices/af_bella.pt
Normal file
BIN
api/src/voices/af_bella.pt
Normal file
Binary file not shown.
BIN
api/src/voices/af_nicole.pt
Normal file
BIN
api/src/voices/af_nicole.pt
Normal file
Binary file not shown.
BIN
api/src/voices/af_sarah.pt
Normal file
BIN
api/src/voices/af_sarah.pt
Normal file
Binary file not shown.
BIN
api/src/voices/af_sky.pt
Normal file
BIN
api/src/voices/af_sky.pt
Normal file
Binary file not shown.
BIN
api/src/voices/am_adam.pt
Normal file
BIN
api/src/voices/am_adam.pt
Normal file
Binary file not shown.
BIN
api/src/voices/am_michael.pt
Normal file
BIN
api/src/voices/am_michael.pt
Normal file
Binary file not shown.
BIN
api/src/voices/bf_emma.pt
Normal file
BIN
api/src/voices/bf_emma.pt
Normal file
Binary file not shown.
BIN
api/src/voices/bf_isabella.pt
Normal file
BIN
api/src/voices/bf_isabella.pt
Normal file
Binary file not shown.
BIN
api/src/voices/bm_george.pt
Normal file
BIN
api/src/voices/bm_george.pt
Normal file
Binary file not shown.
BIN
api/src/voices/bm_lewis.pt
Normal file
BIN
api/src/voices/bm_lewis.pt
Normal file
Binary file not shown.
|
@ -1,10 +1,10 @@
|
|||
name: kokoro-tts
|
||||
services:
|
||||
kokoro-tts:
|
||||
image: ghcr.io/remsky/kokoro-fastapi-cpu:v0.1.0
|
||||
# build:
|
||||
# context: ../..
|
||||
# dockerfile: docker/cpu/Dockerfile
|
||||
# image: ghcr.io/remsky/kokoro-fastapi-cpu:v0.1.0
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: docker/cpu/Dockerfile
|
||||
volumes:
|
||||
- ../../api/src:/app/api/src
|
||||
- ../../api/src/voices:/app/api/src/voices
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
name: kokoro-tts
|
||||
services:
|
||||
kokoro-tts:
|
||||
image: ghcr.io/remsky/kokoro-fastapi-gpu:v0.1.0
|
||||
# build:
|
||||
# context: ../..
|
||||
# dockerfile: docker/gpu/Dockerfile
|
||||
# image: ghcr.io/remsky/kokoro-fastapi-gpu:v0.1.0
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: docker/gpu/Dockerfile
|
||||
volumes:
|
||||
- ../../api/src:/app/api/src # Mount src for development
|
||||
- ../../api/src/voices:/app/api/src/voices # Mount voices for persistence
|
||||
|
|
Loading…
Add table
Reference in a new issue