asdrty123 commited on
Commit
4caa500
·
verified ·
1 Parent(s): 4de24bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -18
app.py CHANGED
@@ -39,29 +39,39 @@ tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voice
39
  tts_voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
40
 
41
  model_root = "weights"
42
- models = [
 
 
43
  d for d in os.listdir(model_root) if os.path.isdir(os.path.join(model_root, d))
44
  ]
45
- if len(models) == 0:
46
- raise ValueError("No model found in `weights` folder")
47
- models.sort()
48
-
49
 
50
- REPO_ID = "simpsonsaiorg/stream-models" # your repo
 
51
  api = HfApi()
52
 
53
- # Get all files in the repo
54
  all_files = api.list_repo_files(REPO_ID)
55
- print('ALL FILES')
56
- print(all_files)
57
- # Group files by model folder
58
- #models = defaultdict(list)
59
  for f in all_files:
60
  parts = f.split("/")
61
- if len(parts) == 2: # weights/model_name/file.pt
62
- models[parts[0]].append(parts[1])
 
 
 
 
 
 
 
 
 
 
63
 
64
  # Example: load a specific model (like your hubert loader)
 
65
  def load_model(model_name):
66
  if model_name not in models:
67
  raise ValueError(f"Model '{model_name}' not found in repo")
@@ -72,13 +82,9 @@ def load_model(model_name):
72
  loaded[file] = torch.load(path, map_location="cpu")
73
  return loaded
74
 
75
- # List available models
76
- available_models = list(models.keys())
77
- print("Available models:", available_models)
78
-
79
  # Load homer model
80
  #homer_model = load_model("homer")
81
-
82
 
83
 
84
 
 
39
  tts_voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
40
 
41
  model_root = "weights"
42
+
43
+ # ---- Local models ----
44
+ local_models = [
45
  d for d in os.listdir(model_root) if os.path.isdir(os.path.join(model_root, d))
46
  ]
47
+ if not local_models:
48
+ print("⚠️ No model found in local `weights` folder")
49
+ local_models.sort()
 
50
 
51
+ # ---- HF models ----
52
+ REPO_ID = "simpsonsaiorg/stream-models"
53
  api = HfApi()
54
 
 
55
  all_files = api.list_repo_files(REPO_ID)
56
+
57
+ hf_models = defaultdict(list)
 
 
58
  for f in all_files:
59
  parts = f.split("/")
60
+ if len(parts) == 3 and parts[0] == "weights":
61
+ model_name, filename = parts[1], parts[2]
62
+ hf_models[model_name].append(filename)
63
+
64
+ # ---- Merge / display ----
65
+ available_models = sorted(set(local_models) | set(hf_models.keys()))
66
+
67
+ print("Local models:", local_models)
68
+ print("HF models:", list(hf_models.keys()))
69
+ print("Available models (combined):", available_models)
70
+
71
+
72
 
73
  # Example: load a specific model (like your hubert loader)
74
+ """
75
  def load_model(model_name):
76
  if model_name not in models:
77
  raise ValueError(f"Model '{model_name}' not found in repo")
 
82
  loaded[file] = torch.load(path, map_location="cpu")
83
  return loaded
84
 
 
 
 
 
85
  # Load homer model
86
  #homer_model = load_model("homer")
87
+ """
88
 
89
 
90