Skip to content

feat: add Qwen3-ASR streaming WebSocket server with notes#3035

Merged
LauraGPT merged 4 commits into
modelscope:mainfrom
qiulang:qwen3-asr-ws-example
Jun 28, 2026
Merged

feat: add Qwen3-ASR streaming WebSocket server with notes#3035
LauraGPT merged 4 commits into
modelscope:mainfrom
qiulang:qwen3-asr-ws-example

Conversation

@qiulang

@qiulang qiulang commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

基于 #3006 最后的讨论,提交 Qwen3-ASR streaming WebSocket server 的示例代码,还有中英文使用说明。

使用说明的第一段,关于vad的描述,是我个人的理解,需要review。 我在说明里标注了 ”以下是我的个人理解“, 所以最后修改合入后需要把这句话删掉。

@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 introduces a streaming WebSocket service for Qwen3-ASR (serve_qwen3_asr_ws.py) along with detailed documentation in both Chinese and English explaining VAD integration, vLLM version requirements, and tokenizer warnings. The feedback suggests improving the WebSocket connection handler by catching and logging general exceptions to prevent silent failures and simplify troubleshooting.

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 on lines +107 to +108
except websockets.exceptions.ConnectionClosed:
pass

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.

medium

建议在 handle_client 中增加对通用异常(Exception)的捕获并记录日志。目前仅捕获了 websockets.exceptions.ConnectionClosed,如果发生其他未预期的异常(例如音频数据转换错误或模型推理异常),连接会直接中断且没有任何错误日志,这会增加排查问题的难度。可以参考 serve_realtime_ws.py 中的异常处理设计。

Suggested change
except websockets.exceptions.ConnectionClosed:
pass
except websockets.exceptions.ConnectionClosed:
pass
except Exception as e:
logging.error(f"Error in handle_client: {e}", exc_info=True)

@LauraGPT

Copy link
Copy Markdown
Collaborator

谢谢 @qiulang,这个 PR 正好接上 #3006 后面的 Qwen3-ASR streaming WebSocket 例子方向,我已经先推了一个小的 polish commit 到这个分支:

  • 删掉了中英文 notes 里的“个人理解 / personal understanding”占位句,保留正式说明口径;
  • 按 Gemini review 的建议给 handle_client 加了通用异常日志,断连仍然静默处理,其他异常会 logging.exception 打出来;
  • 加了一个轻量 tests/test_qwen3_asr_ws_example.py,防止这两个点后续回退。

我这边已验证:

python -m unittest tests.test_qwen3_asr_ws_example -v
python -m py_compile examples/industrial_data_pretraining/qwen3_asr/serve_qwen3_asr_ws.py tests/test_qwen3_asr_ws_example.py
git diff --check HEAD~1..HEAD

另外用 fake qwen_asrind-gpu8venv_nano_vllm 里跑了 WebSocket 协议 smoke,START / audio chunk / STOP 路径能返回 started、partial、final、stopped。

我这边暂时没有现成的 qwen_asr + vLLM 0.14 真实环境,所以还没跑真实 Qwen3-ASR 模型端到端。麻烦你方便时再用你原来的 qwen-asr 环境确认一下真实模型启动和一条短音频转写;确认 OK 后我再合。

@qiulang

qiulang commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

我的环境验证你的测试没问题

(qwen3_env2) vllm@VM-0-9-ubuntu:~/funasr/FunASR$ python -m unittest tests.test_qwen3_asr_ws_example -v
test_handler_logs_unexpected_exceptions (tests.test_qwen3_asr_ws_example.Qwen3AsrWebsocketExampleTest.test_handler_logs_unexpected_exceptions) ... ok
test_notes_do_not_contain_review_placeholders (tests.test_qwen3_asr_ws_example.Qwen3AsrWebsocketExampleTest.test_notes_do_not_contain_review_placeholders) ... ok

----------------------------------------------------------------------
Ran 2 tests in 0.002s

OK
(qwen3_env2) vllm@VM-0-9-ubuntu:~/funasr/FunASR$ python -m py_compile examples/industrial_data_pretraining/qwen3_asr/serve_qwen3_asr_ws.py tests/test_qwen3_asr_ws_example.py
(qwen3_env2) vllm@VM-0-9-ubuntu:~/funasr/FunASR$ echo $?
0

不过有一点要提示一下 我的环境为了git clone 快是这样的 git clone --depth 1 --filter=blob:none --sparse \ https://gh-proxy.com/https://github.com/modelscope/FunASR.git 所以跑测试就没有用你的tests/run_test.py 而是先 touch FunASR/tests/__init__.py

所以还没跑真实 Qwen3-ASR 模型端到端。麻烦你方便时再用你原来的 qwen-asr 环境确认一下真实模型启动和一条短音频转写;确认 OK 后我再合。

这个没问题。因为我一直就是用我的这个代码做压力测试

# 服务器
 python  examples/industrial_data_pretraining/qwen3_asr/serve_qwen3_asr_ws.py --model  /home/vllm/funasr/models/Qwen3-ASR-1dot7B
 
# 测试
python funasr-test-scripts/bench_streaming_ws.py --audio test-audio-sample/卖炭翁.wav

@qiulang

qiulang commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

我发现我的notes 需要对模型下载做个提示 ,就是把 https://github.com/QwenLM/Qwen3-ASR#released-models-description-and-download 再补充一下,等我提交一下

@qiulang

qiulang commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

commit id fde257d : "docs: add model download notes (offline / HF-unreachable)"

@LauraGPT LauraGPT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the new Qwen3-ASR WebSocket example and notes. Verified unittest, py_compile, diff whitespace checks, and the contributor confirmed real qwen_asr/vLLM usage with an audio bench run.

@LauraGPT LauraGPT merged commit 8f8ce5f into modelscope:main Jun 28, 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.

2 participants