Skip to content

feat(server): add --model-path and --hub options to funasr-server#3299

Open
liudonghua123 wants to merge 1 commit into
modelscope:mainfrom
liudonghua123:feat-funasr-server-support-model-path-and-hub
Open

feat(server): add --model-path and --hub options to funasr-server#3299
liudonghua123 wants to merge 1 commit into
modelscope:mainfrom
liudonghua123:feat-funasr-server-support-model-path-and-hub

Conversation

@liudonghua123

Copy link
Copy Markdown
  • 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

Summary

Type of change

  • Bug fix
  • Documentation
  • Example or demo
  • Runtime or deployment
  • Benchmark or evaluation
  • Model/training change

Validation

  • python -m compileall funasr examples tests
  • Docs or links checked
  • Runtime/deployment command tested

User impact

Nothing.

Notes for reviewers

- 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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread funasr/bin/_server_app.py
Comment on lines 178 to 180
return None
from funasr import AutoModel
cfg = FALLBACK_CONFIGS[name].copy()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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.

Suggested change
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()

Comment thread funasr/bin/_server_app.py
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"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
vllm_hub = app.state.hub if app.state.hub else "hf"
vllm_hub = app.state.hub if app.state.model_path else "hf"

Comment thread funasr/bin/_server_app.py
"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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
"hub": app.state.hub if app.state.hub else "hf",
"hub": app.state.hub if app.state.model_path else "hf",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant