Gamahea commited on
Commit
1594e97
·
1 Parent(s): a3883d4

Deploy Music Generation Studio - 2025-12-12 18:06

Browse files
backend/services/diffrhythm_service.py CHANGED
@@ -123,16 +123,22 @@ class DiffRhythmService:
123
 
124
  # Load tokenizer
125
  from g2p.g2p_generation import chn_eng_g2p
126
- vocab_path = os.path.join(self.model_path, "vocab.json")
127
- if not os.path.exists(vocab_path):
128
- # Download vocab
 
 
 
 
 
129
  vocab_path = hf_hub_download(
130
  repo_id=repo_id,
131
- filename="g2p/g2p/vocab.json",
132
  local_dir=self.model_path,
133
  local_files_only=False,
134
  )
135
 
 
136
  with open(vocab_path, 'r') as f:
137
  phone2id = json.load(f)['vocab']
138
 
 
123
 
124
  # Load tokenizer
125
  from g2p.g2p_generation import chn_eng_g2p
126
+
127
+ # Look for vocab.json in the cloned DiffRhythm2 source
128
+ diffrhythm2_src = Path(__file__).parent.parent.parent / "models" / "diffrhythm2_source"
129
+ vocab_path = diffrhythm2_src / "g2p" / "g2p" / "vocab.json"
130
+
131
+ if not vocab_path.exists():
132
+ # Fallback: try downloading from HF Hub
133
+ logger.warning(f"vocab.json not found at {vocab_path}, trying to download from HF Hub")
134
  vocab_path = hf_hub_download(
135
  repo_id=repo_id,
136
+ filename="vocab.json",
137
  local_dir=self.model_path,
138
  local_files_only=False,
139
  )
140
 
141
+ logger.info(f"Loading vocab from: {vocab_path}")
142
  with open(vocab_path, 'r') as f:
143
  phone2id = json.load(f)['vocab']
144