binhqd commited on
Commit
167fa74
·
1 Parent(s): 8c740c9

Add custom inference handler for Maya1 TTS

Browse files
Files changed (1) hide show
  1. handler.py +7 -6
handler.py CHANGED
@@ -50,14 +50,15 @@ class EndpointHandler:
50
  device_map_arg = "cpu"
51
 
52
  # Allow loading from HuggingFace Hub via environment variable
53
- # MAYA_MODEL_ID: HuggingFace model ID (e.g., "Plachta/MARS5-TTS" or similar Maya model)
54
  model_id = os.getenv("MAYA_MODEL_ID", "")
55
 
56
  # Determine model path: use env var if set, otherwise local path
57
  local_path = path if path else "/repository"
58
 
59
  # Check if trying to load from self (circular reference)
60
- if model_id and (model_id == "binhqd/maya1" or model_id.endswith("/maya1")):
 
61
  print(f"⚠️ MAYA_MODEL_ID is set to {model_id} which is this repository!")
62
  print("This creates a circular reference. Checking local files instead...")
63
  model_id = "" # Force local loading
@@ -82,8 +83,8 @@ class EndpointHandler:
82
  f" This generates test audio (sine wave) without requiring model files.\n\n"
83
  f"2. 🌐 USE EXISTING MODEL FROM HUGGINGFACE:\n"
84
  f" Set: MAYA_MODEL_ID=<actual-model-id>\n"
85
- f" Example: MAYA_MODEL_ID=facebook/musicgen-small\n"
86
- f" (You need to find or specify a real TTS model on HuggingFace)\n\n"
87
  f"3. 📦 UPLOAD YOUR MODEL FILES:\n"
88
  f" Upload these files to your repository (binhqd/maya1):\n"
89
  f" - config.json\n"
@@ -93,8 +94,8 @@ class EndpointHandler:
93
  f" - generation_config.json (optional)\n\n"
94
  f"Current path: {model_path}\n"
95
  f"Files found: {os.listdir(model_path) if os.path.exists(model_path) else 'path does not exist'}\n\n"
96
- f"⚠️ Note: MAYA_MODEL_ID cannot point to binhqd/maya1 (this repository)\n"
97
- f" because it doesn't contain model weights yet.\n"
98
  )
99
 
100
  try:
 
50
  device_map_arg = "cpu"
51
 
52
  # Allow loading from HuggingFace Hub via environment variable
53
+ # MAYA_MODEL_ID: HuggingFace model ID (e.g., "maya-research/maya1" or similar Maya model)
54
  model_id = os.getenv("MAYA_MODEL_ID", "")
55
 
56
  # Determine model path: use env var if set, otherwise local path
57
  local_path = path if path else "/repository"
58
 
59
  # Check if trying to load from self (circular reference)
60
+ # Only block if it's exactly "binhqd/maya1" - other repos ending in /maya1 are fine
61
+ if model_id == "binhqd/maya1":
62
  print(f"⚠️ MAYA_MODEL_ID is set to {model_id} which is this repository!")
63
  print("This creates a circular reference. Checking local files instead...")
64
  model_id = "" # Force local loading
 
83
  f" This generates test audio (sine wave) without requiring model files.\n\n"
84
  f"2. 🌐 USE EXISTING MODEL FROM HUGGINGFACE:\n"
85
  f" Set: MAYA_MODEL_ID=<actual-model-id>\n"
86
+ f" Example: MAYA_MODEL_ID=maya-research/maya1\n"
87
+ f" (Must be a valid HuggingFace model repository with weights)\n\n"
88
  f"3. 📦 UPLOAD YOUR MODEL FILES:\n"
89
  f" Upload these files to your repository (binhqd/maya1):\n"
90
  f" - config.json\n"
 
94
  f" - generation_config.json (optional)\n\n"
95
  f"Current path: {model_path}\n"
96
  f"Files found: {os.listdir(model_path) if os.path.exists(model_path) else 'path does not exist'}\n\n"
97
+ f"⚠️ Note: MAYA_MODEL_ID=binhqd/maya1 won't work (this repository)\n"
98
+ f" because it doesn't contain model weights.\n"
99
  )
100
 
101
  try: