(args)
| 169 | |
| 170 | |
| 171 | def load_model(args): |
| 172 | from voxcpm.core import VoxCPM |
| 173 | |
| 174 | print("Loading VoxCPM model...", file=sys.stderr) |
| 175 | |
| 176 | zipenhancer_path = getattr(args, "zipenhancer_path", None) or os.environ.get( |
| 177 | "ZIPENHANCER_MODEL_PATH", None |
| 178 | ) |
| 179 | |
| 180 | # Build LoRA config if provided |
| 181 | lora_config = None |
| 182 | lora_weights_path = getattr(args, "lora_path", None) |
| 183 | if lora_weights_path: |
| 184 | from voxcpm.model.voxcpm import LoRAConfig |
| 185 | |
| 186 | lora_config = LoRAConfig( |
| 187 | enable_lm=not args.lora_disable_lm, |
| 188 | enable_dit=not args.lora_disable_dit, |
| 189 | enable_proj=args.lora_enable_proj, |
| 190 | r=args.lora_r, |
| 191 | alpha=args.lora_alpha, |
| 192 | dropout=args.lora_dropout, |
| 193 | ) |
| 194 | |
| 195 | print( |
| 196 | f"LoRA config: r={lora_config.r}, alpha={lora_config.alpha}, " |
| 197 | f"lm={lora_config.enable_lm}, dit={lora_config.enable_dit}, proj={lora_config.enable_proj}", |
| 198 | file=sys.stderr, |
| 199 | ) |
| 200 | |
| 201 | # Load local model if specified |
| 202 | if args.model_path: |
| 203 | try: |
| 204 | model = VoxCPM( |
| 205 | voxcpm_model_path=args.model_path, |
| 206 | zipenhancer_model_path=zipenhancer_path, |
| 207 | enable_denoiser=not args.no_denoiser, |
| 208 | optimize=not args.no_optimize, |
| 209 | device=args.device, |
| 210 | lora_config=lora_config, |
| 211 | lora_weights_path=lora_weights_path, |
| 212 | ) |
| 213 | print("Model loaded (local).", file=sys.stderr) |
| 214 | return model |
| 215 | except Exception as e: |
| 216 | print(f"Failed to load model (local): {e}", file=sys.stderr) |
| 217 | sys.exit(1) |
| 218 | |
| 219 | # Load from Hugging Face Hub |
| 220 | try: |
| 221 | model = VoxCPM.from_pretrained( |
| 222 | hf_model_id=args.hf_model_id, |
| 223 | load_denoiser=not args.no_denoiser, |
| 224 | zipenhancer_model_id=zipenhancer_path, |
| 225 | cache_dir=args.cache_dir, |
| 226 | local_files_only=args.local_files_only, |
| 227 | optimize=not args.no_optimize, |
| 228 | device=args.device, |
no test coverage detected
searching dependent graphs…