Repository navigation
fix(websocket): build the offline model from --asr_model - #3887
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3886
Since #2791,
runtime/python/websocket/funasr_wss_server.pybuilt its offline model from a fixed"paraformer-zh"and"v2.0.4", although it parses--asr_modeland--asr_model_revisionand 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 ranparaformer-zhfor 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_modelbecomes"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_revisionalready defaults tov2.0.4.The model and revision that the offline model's
AutoModelcall receives (the script in the issue):mainparaformer-zhv2.0.4--asr_model paraformer-enparaformer-zhv2.0.4paraformer-env2.0.4--asr_model /models/my-paraformer --asr_model_revision masterparaformer-zhv2.0.4/models/my-paraformermasterType of change
Validation
The new
tests/test_websocket_server_asr_model.pyruns the realfunasr_wss_server.pymodule (the server builds its models when it is imported) withAutoModelreplaced by a recorder, and with empty stand-ins forwebsockets,scipyandtorch, 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:
main(6f52414) server with the new test: 2 failed, 29 passed:assert 'paraformer-zh' == 'paraformer-en'andassert 'paraformer-zh' == '/models/my-paraformer'.This branch: 31 passed, also with
-W error.python -m compileall funasr examples tests(andruntime/python/websocket)Docs or links checked
Runtime/deployment command tested (the server's startup: its real argument parsing and model construction, with
AutoModelreplaced; 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 tofunasr_wss_server.pyonmainand 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 ranparaformer-zhv2.0.4 whatever they passed. A server started without these options loadsparaformer-zhv2.0.4 as before.Notes for reviewers
--asr_modelis the model the server has loaded since Codex/create training and inference scripts #2791, not the Contextual Paraformer that the option named, so that servers started without options keep their model.runtime/python/websocket/**, so CI does not run this test (ortests/test_websocket_file_finalization.py). I can add it to a workflow if you want.git merge-tree --write-treeof this branch with the heads of fix(websocket): pass client hotwords to AutoModel as words #3880 and Fix/security hardening #3877, which also editfunasr_wss_server.py, gives no conflicts. On the tree merged with fix(websocket): pass client hotwords to AutoModel as words #3880, this test, itstests/test_websocket_server_hotwords.pyandtests/test_websocket_file_finalization.pygive 36 passed (run with stand-inwebsockets,scipyandtorchmodules, which my test environment does not have).