From 0735999c59dd35d9d6ddb77ea724097bdf04b4e1 Mon Sep 17 00:00:00 2001 From: Kim Date: Sat, 15 Mar 2025 02:19:25 +1300 Subject: [PATCH 1/2] Add Windows powershell scripts --- README.md | 8 ++++++++ start-cpu.ps1 | 16 ++++++++++++++++ start-gpu.ps1 | 17 +++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 start-cpu.ps1 create mode 100644 start-gpu.ps1 diff --git a/README.md b/README.md index eb90b4d..6859163 100644 --- a/README.md +++ b/README.md @@ -91,11 +91,19 @@ docker run --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:v0.2.2 #NV Run the [model download script](https://github.com/remsky/Kokoro-FastAPI/blob/master/docker/scripts/download_model.py) if you haven't already Start directly via UV (with hot-reload) + + Linux and macOS ```bash ./start-cpu.sh OR ./start-gpu.sh ``` + Windows + ```powershell + .\start-cpu.ps1 OR + .\start-gpu.ps1 + ``` +
diff --git a/start-cpu.ps1 b/start-cpu.ps1 new file mode 100644 index 0000000..a810841 --- /dev/null +++ b/start-cpu.ps1 @@ -0,0 +1,16 @@ +$env:PHONEMIZER_ESPEAK_LIBRARY="C:\Program Files\eSpeak NG\libespeak-ng.dll" +$env:PYTHONUTF8=1 +$Env:PROJECT_ROOT="$pwd" +$Env:USE_GPU="false" +$Env:USE_ONNX="false" +$Env:PYTHONPATH="$Env:PROJECT_ROOT;$Env:PROJECT_ROOT/api" +$Env:MODEL_DIR="src/models" +$Env:VOICES_DIR="src/voices/v1_0" +$Env:WEB_PLAYER_PATH="$Env:PROJECT_ROOT/web" + +uv pip install wheel setuptools ninja typing_extensions>=4.10.0 fastapi uvicorn + +uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 +uv pip install -e ".[cpu]" + +uv run --no-sync uvicorn api.src.main:app --host 0.0.0.0 --port 8880 diff --git a/start-gpu.ps1 b/start-gpu.ps1 new file mode 100644 index 0000000..6a2a111 --- /dev/null +++ b/start-gpu.ps1 @@ -0,0 +1,17 @@ +$env:PHONEMIZER_ESPEAK_LIBRARY="C:\Program Files\eSpeak NG\libespeak-ng.dll" +$env:PYTHONUTF8=1 +$Env:PROJECT_ROOT="$pwd" +$Env:USE_GPU="true" +$Env:USE_ONNX="false" +$Env:PYTHONPATH="$Env:PROJECT_ROOT;$Env:PROJECT_ROOT/api" +$Env:MODEL_DIR="src/models" +$Env:VOICES_DIR="src/voices/v1_0" +$Env:WEB_PLAYER_PATH="$Env:PROJECT_ROOT/web" + +uv pip install wheel setuptools ninja typing_extensions>=4.10.0 fastapi uvicorn + +uv pip install torch==2.6.0+cu124 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 +uv pip install -e ".[gpu]" + + +uv run --no-sync uvicorn api.src.main:app --host 0.0.0.0 --port 8880 From 22185dbc8971137035990814b5296f80ca8f217b Mon Sep 17 00:00:00 2001 From: Fireblade Date: Sat, 15 Mar 2025 16:35:06 -0400 Subject: [PATCH 2/2] Fixed the ps1 files downloading packages before the venv and made all starrt scripts auto download models --- start-cpu.ps1 | 7 ++----- start-cpu.sh | 1 + start-gpu.ps1 | 8 ++------ start-gpu.sh | 2 ++ 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/start-cpu.ps1 b/start-cpu.ps1 index a810841..5a5df26 100644 --- a/start-cpu.ps1 +++ b/start-cpu.ps1 @@ -8,9 +8,6 @@ $Env:MODEL_DIR="src/models" $Env:VOICES_DIR="src/voices/v1_0" $Env:WEB_PLAYER_PATH="$Env:PROJECT_ROOT/web" -uv pip install wheel setuptools ninja typing_extensions>=4.10.0 fastapi uvicorn - -uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 uv pip install -e ".[cpu]" - -uv run --no-sync uvicorn api.src.main:app --host 0.0.0.0 --port 8880 +uv run --no-sync python docker/scripts/download_model.py --output api/src/models/v1_0 +uv run --no-sync uvicorn api.src.main:app --host 0.0.0.0 --port 8880 \ No newline at end of file diff --git a/start-cpu.sh b/start-cpu.sh index 651f645..4438ff9 100755 --- a/start-cpu.sh +++ b/start-cpu.sh @@ -14,4 +14,5 @@ export WEB_PLAYER_PATH=$PROJECT_ROOT/web # Run FastAPI with CPU extras using uv run # Note: espeak may still require manual installation, uv pip install -e ".[cpu]" +uv run --no-sync python docker/scripts/download_model.py --output api/src/models/v1_0 uv run --no-sync uvicorn api.src.main:app --host 0.0.0.0 --port 8880 diff --git a/start-gpu.ps1 b/start-gpu.ps1 index 6a2a111..7b161a5 100644 --- a/start-gpu.ps1 +++ b/start-gpu.ps1 @@ -8,10 +8,6 @@ $Env:MODEL_DIR="src/models" $Env:VOICES_DIR="src/voices/v1_0" $Env:WEB_PLAYER_PATH="$Env:PROJECT_ROOT/web" -uv pip install wheel setuptools ninja typing_extensions>=4.10.0 fastapi uvicorn - -uv pip install torch==2.6.0+cu124 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 uv pip install -e ".[gpu]" - - -uv run --no-sync uvicorn api.src.main:app --host 0.0.0.0 --port 8880 +uv run --no-sync python docker/scripts/download_model.py --output api/src/models/v1_0 +uv run --no-sync uvicorn api.src.main:app --host 0.0.0.0 --port 8880 \ No newline at end of file diff --git a/start-gpu.sh b/start-gpu.sh index b079978..a3a2e68 100755 --- a/start-gpu.sh +++ b/start-gpu.sh @@ -12,5 +12,7 @@ export VOICES_DIR=src/voices/v1_0 export WEB_PLAYER_PATH=$PROJECT_ROOT/web # Run FastAPI with GPU extras using uv run +# Note: espeak may still require manual installation, uv pip install -e ".[gpu]" +uv run --no-sync python docker/scripts/download_model.py --output api/src/models/v1_0 uv run --no-sync uvicorn api.src.main:app --host 0.0.0.0 --port 8880