Fix Kokoro model download with correct release URLs
Browse files
app.py
CHANGED
|
@@ -63,17 +63,37 @@ app = FastAPI(title="Kokoro TTS API - Professional & Fast")
|
|
| 63 |
def startup():
|
| 64 |
global kokoro
|
| 65 |
if kokoro is None:
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
init_admin()
|
| 79 |
|
|
|
|
| 63 |
def startup():
|
| 64 |
global kokoro
|
| 65 |
if kokoro is None:
|
| 66 |
+
import urllib.request
|
| 67 |
+
import os
|
| 68 |
+
|
| 69 |
+
print("📥 Downloading Kokoro TTS model files...")
|
| 70 |
+
|
| 71 |
+
# Create directory for voices
|
| 72 |
+
os.makedirs("voices", exist_ok=True)
|
| 73 |
+
|
| 74 |
+
# Download voices file
|
| 75 |
+
voices_file = "voices/voices.bin"
|
| 76 |
+
if not os.path.exists(voices_file):
|
| 77 |
+
print("Downloading voices.bin...")
|
| 78 |
+
urllib.request.urlretrieve(
|
| 79 |
+
"https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/voices.bin",
|
| 80 |
+
voices_file
|
| 81 |
+
)
|
| 82 |
+
print("✅ Voices downloaded!")
|
| 83 |
+
|
| 84 |
+
# Download ONNX model
|
| 85 |
+
model_file = "kokoro-v0_19.onnx"
|
| 86 |
+
if not os.path.exists(model_file):
|
| 87 |
+
print("Downloading kokoro-v0_19.onnx...")
|
| 88 |
+
urllib.request.urlretrieve(
|
| 89 |
+
"https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/kokoro-v0_19.onnx",
|
| 90 |
+
model_file
|
| 91 |
+
)
|
| 92 |
+
print("✅ Model downloaded!")
|
| 93 |
+
|
| 94 |
+
print("🎤 Initializing Kokoro TTS...")
|
| 95 |
+
kokoro = Kokoro(model_file, voices_file)
|
| 96 |
+
print("✅ Kokoro TTS loaded!")
|
| 97 |
|
| 98 |
init_admin()
|
| 99 |
|