Skip to content

fix(websocket): build the offline model from --asr_model - #3887

Merged
LauraGPT merged 1 commit into
modelscope:mainfrom
tanishqbaweja:fix/wss-server-asr-model
Nov 13, 2026
Merged

LauraGPT merged 1 commit into
modelscope:mainfrom
tanishqbaweja:fix/wss-server-asr-model

Conversation

@tanishqbaweja

Copy link
Copy Markdown
Contributor

Summary

Fixes #3886

Since #2791, runtime/python/websocket/funasr_wss_server.py built its offline model from a fixed "paraformer-zh" and "v2.0.4", although it parses --asr_model and --asr_model_revision and the README lists --asr_model (runtime/python/websocket/README.md:29). Both options had no effect: a server started with --asr_model paraformer-en, or with the directory of a fine-tuned model, still ran paraformer-zh for its offline and 2pass-offline results.

This PR builds the offline model from the two options again, as the streaming, VAD and punctuation models are built from theirs (two lines). So that a server started without these options keeps its model, the default of --asr_model becomes "paraformer-zh" (one line). It named the Contextual Paraformer (iic/speech_paraformer-large-contextual_asr_nat-zh-cn-16k-common-vocab8404), which the server did not load. --asr_model_revision already defaults to v2.0.4.

The model and revision that the offline model's AutoModel call receives (the script in the issue):

options main this PR
none paraformer-zh v2.0.4 unchanged
--asr_model paraformer-en paraformer-zh v2.0.4 paraformer-en v2.0.4
--asr_model /models/my-paraformer --asr_model_revision master paraformer-zh v2.0.4 /models/my-paraformer master

Type of change

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

Validation

The new tests/test_websocket_server_asr_model.py runs the real funasr_wss_server.py module (the server builds its models when it is imported) with AutoModel replaced by a recorder, and with empty stand-ins for websockets, scipy and torch, which the server uses only to serve requests. So it needs only numpy. It checks the model and revision of the offline model without options, with --asr_model paraformer-en, and with a model directory and --asr_model_revision master, and that the streaming model keeps --asr_model_online.

Windows 11, CPU, Python 3.11.17, numpy 1.26.4, pytest 9.2.0:

python -m pytest -q tests/test_websocket_server_asr_model.py tests/test_websocket_file_finalization.py
  • main (6f52414) server with the new test: 2 failed, 29 passed: assert 'paraformer-zh' == 'paraformer-en' and assert 'paraformer-zh' == '/models/my-paraformer'.

  • This branch: 31 passed, also with -W error.

  • python -m compileall funasr examples tests (and runtime/python/websocket)

  • Docs or links checked

  • Runtime/deployment command tested (the server's startup: its real argument parsing and model construction, with AutoModel replaced; no model was loaded and no socket was served)

black --line-length=100 (24.4.0, as in pre-commit) leaves the new test unchanged, and makes the same changes to funasr_wss_server.py on main and on this branch, none on the changed lines.

User impact

Users who start the Python websocket server with --asr_model, and optionally --asr_model_revision, get that model for offline and 2pass-offline recognition, for example an English model or a fine-tuned model directory. Before, the server ran paraformer-zh v2.0.4 whatever they passed. A server started without these options loads paraformer-zh v2.0.4 as before.

Notes for reviewers

funasr_wss_server.py parses --asr_model and --asr_model_revision, and
the README lists --asr_model, but since modelscope#2791 the server built its
offline model from a fixed "paraformer-zh" v2.0.4. Both options had no
effect, so a server started with another model, such as an English or
a fine-tuned one, still ran paraformer-zh.

Build the offline model from the two options, as the streaming, VAD and
punctuation models are built from theirs. The default of --asr_model
becomes "paraformer-zh" (it named the Contextual Paraformer, which the
server did not load), so a server started without these options loads
the same model as before.

Add tests/test_websocket_server_asr_model.py: it runs the server module
with AutoModel replaced and checks the model and revision of the
offline model, with and without the options.
LauraGPT added a commit that referenced this pull request Nov 13, 2026
Preserve the original #3887 fix and contributor ancestry. Add scoped Python 3.10/3.11/3.12 protocol regression CI.

Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
LauraGPT added a commit that referenced this pull request Nov 13, 2026
Preserve original #3887 ancestry; accept scoped CPU, real CUDA synthetic-routing and exact-head hosted CI evidence. No pretrained-quality or full-suite claim.

Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
@LauraGPT
LauraGPT merged commit baf0e8e into modelscope:main Nov 13, 2026
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.

funasr_wss_server.py ignores --asr_model and --asr_model_revision: the offline model is always paraformer-zh v2.0.4

2 participants