fix(qwen): 去掉字幕里的 language Chinese / asr_text 模板残留 - #442
Open
learning-kai wants to merge 3 commits into
Open
Conversation
Qwen3-ASR sometimes emits chat-template crumbs such as language Chinese<asr_text> into cue text. Sanitize at the worker and engine exits, and drop empty leftover cues.
learning-kai
marked this pull request as ready for review
August 15, 2026 10:45
Author
问题用 Qwen3-ASR 转写时会出现三类脏输出:
真实课字幕里的脏形态例如: 变更内容
验证
已有字幕文件不会自动改写,需要重新转写才会变干净。 |
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.
问题
用 Qwen3-ASR 转写时会出现三类脏输出:
字幕里时不时冒出
language Chinese,有时还带着<asr_text>。这是 Qwen3-ASR 的聊天模板漏进正文。模型每段先报语种,再跟听写内容,sherpa-onnx 把整段解码原文交出来,SmartSub 原先原样写入 SRT。
转写直接报
SyntaxError: Bad control character in string literal in JSON at position 59。原生识别结果是一段 JSON 字符串。Qwen 正文里偶尔带未转义的换行、Tab、NUL 等 C0 控制字符,
JSON.parse直接炸掉,整段字幕失败。静音/幻听时整条 cue 变成英文碎片,例如
demand、detract.、imageUrl、Finds.。这不是模板前缀,是模型在无语音段乱吐拉丁词。只剥
<asr_text>去不掉。真实课字幕里的脏形态例如:
变更内容
sanitizeQwenAsrText,剥掉语种头、<asr_text>和偶发 markdown 星号;剥完为空的 cue 丢弃p/DXY/EX1)、数学符号名(sigma)和口语短回应(OK)保留language is important)不会被误删qwenEngine写 SRT 前清洗qwen3_asr同步剥一层json-result.js,解析原生 JSON 前把字符串里的裸控制字符转义;decodeAsync/getResult都走这条路径验证
npm run test:engines:810 passed, 0 failednpm run test:sherpa-json:4 passed已有字幕文件不会自动改写,需要重新转写才会变干净。