feat(server): add --model-path and --hub options to funasr-server#3299
feat(server): add --model-path and --hub options to funasr-server#3299liudonghua123 wants to merge 1 commit into
Conversation
- Add --model-path argument for local model or model ID override - Add --hub argument to specify model hub (ms for ModelScope, hf for HuggingFace) - Support custom model loading via AutoModel with specified path and hub - Update API endpoints to handle 'custom' model type Co-authored-by: liudonghua123 <liudonghua123@gmail.com> Co-authored-by: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request adds support for custom local model paths and model hubs (ModelScope or HuggingFace) to the FunASR server by introducing --model-path and --hub CLI arguments. The review feedback highlights critical issues where loading a custom model via the fallback mechanism would crash due to missing configuration keys, and default models would fail to load because the hub defaults to ModelScope instead of HuggingFace when no custom path is specified.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| return None | ||
| from funasr import AutoModel | ||
| cfg = FALLBACK_CONFIGS[name].copy() |
There was a problem hiding this comment.
If a custom model_path is provided, the model name (e.g., "custom" or "fun-asr-nano") might not be present in FALLBACK_CONFIGS. Currently, _load_fallback will return None for any name not in FALLBACK_CONFIGS, causing a crash when attempting to load or run the custom model. We should allow fallback loading for custom models by returning {} from FALLBACK_CONFIGS and only returning None if app.state.model_path is not set.
| return None | |
| from funasr import AutoModel | |
| cfg = FALLBACK_CONFIGS[name].copy() | |
| if not app.state.model_path: | |
| return None | |
| from funasr import AutoModel | |
| cfg = FALLBACK_CONFIGS.get(name, {}).copy() |
| t0 = time.time() | ||
| # Use custom model_path if provided, otherwise default | ||
| vllm_model = app.state.model_path if app.state.model_path else "FunAudioLLM/Fun-ASR-Nano-2512" | ||
| vllm_hub = app.state.hub if app.state.hub else "hf" |
There was a problem hiding this comment.
The default hub for the fun-asr-nano model is "hf" (HuggingFace). Since app.state.hub defaults to "ms" (ModelScope), if the user does not provide a custom model_path, the server will attempt to load the default "FunAudioLLM/Fun-ASR-Nano-2512" model from ModelScope, which will fail. We should only use app.state.hub if a custom model_path is provided.
| vllm_hub = app.state.hub if app.state.hub else "hf" | |
| vllm_hub = app.state.hub if app.state.model_path else "hf" |
| "model": "FunAudioLLM/Fun-ASR-Nano-2512", | ||
| "hub": "hf", | ||
| "model": app.state.model_path if app.state.model_path else "FunAudioLLM/Fun-ASR-Nano-2512", | ||
| "hub": app.state.hub if app.state.hub else "hf", |
There was a problem hiding this comment.
Similar to the vLLM loader, the fallback loader for fun-asr-nano should only use app.state.hub if a custom model_path is provided, to avoid attempting to load the default HuggingFace model from ModelScope.
| "hub": app.state.hub if app.state.hub else "hf", | |
| "hub": app.state.hub if app.state.model_path else "hf", |
Summary
Type of change
Validation
python -m compileall funasr examples testsUser impact
Nothing.
Notes for reviewers