TGPro1 commited on
Commit
b2f29d9
·
verified ·
1 Parent(s): 7bb29ef

Upload chatterbox_utils.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. chatterbox_utils.py +4 -5
chatterbox_utils.py CHANGED
@@ -129,19 +129,18 @@ def load_chatterbox(device="cuda"):
129
  SESSIONS["tokenizer"] = AutoTokenizer.from_pretrained(MODEL_ID)
130
 
131
  def warmup_chatterbox():
132
- """CPU-only download of model files for caching"""
133
- print("🔥 Warming up Chatterbox (Downloading files)...")
134
  try:
135
  AutoTokenizer.from_pretrained(MODEL_ID)
136
  hf_hub_download(repo_id=MODEL_ID, filename="default_voice.wav")
137
- hf_hub_download(repo_id=MODEL_ID, filename="Cangjie5_TC.json")
138
  for sess_name in ["speech_encoder", "embed_tokens", "conditional_decoder", "language_model"]:
139
  fname = "onnx/" + (sess_name + ".onnx" if sess_name != "language_model" else "language_model.onnx")
140
  hf_hub_download(repo_id=MODEL_ID, filename=fname)
141
  hf_hub_download(repo_id=MODEL_ID, filename=fname + "_data")
142
- print("✅ Chatterbox warmup complete")
143
  except Exception as e:
144
- print(f"⚠️ Chatterbox warmup warning: {e}")
145
 
146
  def run_chatterbox_inference(text, lang_id, speaker_wav_path=None):
147
  """Ported logic from model card with session reuse"""
 
129
  SESSIONS["tokenizer"] = AutoTokenizer.from_pretrained(MODEL_ID)
130
 
131
  def warmup_chatterbox():
132
+ """v92: Pre-download model files in background"""
133
+ print("📥 Caching Chatterbox weights (ONNX)...")
134
  try:
135
  AutoTokenizer.from_pretrained(MODEL_ID)
136
  hf_hub_download(repo_id=MODEL_ID, filename="default_voice.wav")
 
137
  for sess_name in ["speech_encoder", "embed_tokens", "conditional_decoder", "language_model"]:
138
  fname = "onnx/" + (sess_name + ".onnx" if sess_name != "language_model" else "language_model.onnx")
139
  hf_hub_download(repo_id=MODEL_ID, filename=fname)
140
  hf_hub_download(repo_id=MODEL_ID, filename=fname + "_data")
141
+ print("✅ Chatterbox cached.")
142
  except Exception as e:
143
+ print(f"⚠️ Chatterbox cache warning: {e}")
144
 
145
  def run_chatterbox_inference(text, lang_id, speaker_wav_path=None):
146
  """Ported logic from model card with session reuse"""