-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPREDOWNLOAD_MODELS.py
More file actions
65 lines (53 loc) · 2.25 KB
/
Copy pathPREDOWNLOAD_MODELS.py
File metadata and controls
65 lines (53 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
from pathlib import Path
from huggingface_hub import snapshot_download
import httpx
import asyncio
# Konfiguracja
CACHE_BASE = Path("data/cache")
HF_CACHE = CACHE_BASE / "hf"
PIPER_CACHE = CACHE_BASE / "piper"
CACHE_BASE.mkdir(parents=True, exist_ok=True)
HF_CACHE.mkdir(parents=True, exist_ok=True)
PIPER_CACHE.mkdir(parents=True, exist_ok=True)
# Ustaw ścieżkę dla HF Hub
os.environ["HUGGINGFACE_HUB_CACHE"] = str(HF_CACHE)
MODELS_KITTEN = [
"KittenML/kitten-tts-mini-0.8",
"KittenML/kitten-tts-micro-0.8"
]
PIPER_MODELS = {
"pl-gosia": {
"url": "https://huggingface.co/rhasspy/piper-voices/resolve/main/pl/pl_PL/gosia/medium/pl_PL-gosia-medium.onnx",
"config": "https://huggingface.co/rhasspy/piper-voices/resolve/main/pl/pl_PL/gosia/medium/pl_PL-gosia-medium.onnx.json"
},
"pl-darkman": {
"url": "https://huggingface.co/rhasspy/piper-voices/resolve/main/pl/pl_PL/darkman/medium/pl_PL-darkman-medium.onnx",
"config": "https://huggingface.co/rhasspy/piper-voices/resolve/main/pl/pl_PL/darkman/medium/pl_PL-darkman-medium.onnx.json"
}
}
async def download_piper(name: str, info: dict):
onnx_path = PIPER_CACHE / f"{name}.onnx"
json_path = PIPER_CACHE / f"{name}.onnx.json"
async with httpx.AsyncClient() as client:
for key, path in [("url", onnx_path), ("config", json_path)]:
if not path.exists():
print(f"Pobieranie Piper {name} ({key})...")
resp = await client.get(info[key], follow_redirects=True)
resp.raise_for_status()
path.write_bytes(resp.content)
else:
print(f"Piper {name} ({key}) już istnieje.")
async def main():
print("--- Rozpoczynam pobieranie modeli dla Kitten Reader Pro ---")
# KittenTTS
for m in MODELS_KITTEN:
print(f"Pobieranie KittenTTS: {m}...")
snapshot_download(repo_id=m, cache_dir=str(HF_CACHE))
# Piper
for name, info in PIPER_MODELS.items():
await download_piper(name, info)
print("\n[SUKCES] Wszystkie modele zostały pobrane do folderu data/cache.")
print("Teraz możesz przenieść cały folder na inny komputer i uruchomić RUN_PRO.bat.")
if __name__ == "__main__":
asyncio.run(main())