ailuntz commited on
Commit
dfd2f88
·
verified ·
1 Parent(s): 303e19e

Use cached snapshot download for model files

Browse files
Files changed (1) hide show
  1. app.py +12 -16
app.py CHANGED
@@ -16,7 +16,6 @@ from supertonic_mlx import SupertonicMLX
16
  os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "1")
17
 
18
  MODEL_ID = os.environ.get("SUPERTONIC_MLX_MODEL", "mlx-community/supertonic-3")
19
- MODEL_DIR = os.environ.get("SUPERTONIC_MLX_MODEL_DIR", "/models/supertonic-3")
20
  LANGUAGES = [
21
  "en", "ko", "ja", "ar", "bg", "cs", "da", "de", "el", "es", "et", "fi",
22
  "fr", "hi", "hr", "hu", "id", "it", "lt", "lv", "nl", "pl", "pt", "ro",
@@ -27,21 +26,18 @@ VOICES = ["M1", "M2", "M3", "M4", "M5", "F1", "F2", "F3", "F4", "F5"]
27
 
28
  @lru_cache(maxsize=1)
29
  def load_model() -> SupertonicMLX:
30
- if os.path.exists(os.path.join(MODEL_DIR, "tts.json")):
31
- model_dir = MODEL_DIR
32
- else:
33
- model_dir = snapshot_download(
34
- repo_id=MODEL_ID,
35
- repo_type="model",
36
- allow_patterns=[
37
- "graphs/*.json",
38
- "weights/*.npz",
39
- "voice_styles/*.json",
40
- "tts.json",
41
- "unicode_indexer.json",
42
- "mlx_manifest.json",
43
- ],
44
- )
45
  return SupertonicMLX.from_pretrained(model_dir)
46
 
47
 
 
16
  os.environ.setdefault("HF_HUB_ENABLE_HF_TRANSFER", "1")
17
 
18
  MODEL_ID = os.environ.get("SUPERTONIC_MLX_MODEL", "mlx-community/supertonic-3")
 
19
  LANGUAGES = [
20
  "en", "ko", "ja", "ar", "bg", "cs", "da", "de", "el", "es", "et", "fi",
21
  "fr", "hi", "hr", "hu", "id", "it", "lt", "lv", "nl", "pl", "pt", "ro",
 
26
 
27
  @lru_cache(maxsize=1)
28
  def load_model() -> SupertonicMLX:
29
+ model_dir = snapshot_download(
30
+ repo_id=MODEL_ID,
31
+ repo_type="model",
32
+ allow_patterns=[
33
+ "graphs/*.json",
34
+ "weights/*.npz",
35
+ "voice_styles/*.json",
36
+ "tts.json",
37
+ "unicode_indexer.json",
38
+ "mlx_manifest.json",
39
+ ],
40
+ )
 
 
 
41
  return SupertonicMLX.from_pretrained(model_dir)
42
 
43