feat(asr): 新增百炼 Qwen3-ASR-Flash 实时供应商(OpenAI Realtime WS 协议)#775
Open
bigsongeth wants to merge 2 commits into
Open
feat(asr): 新增百炼 Qwen3-ASR-Flash 实时供应商(OpenAI Realtime WS 协议)#775bigsongeth wants to merge 2 commits into
bigsongeth wants to merge 2 commits into
Conversation
三个缺陷叠加导致「阿里云百炼实时 ASR」的连接检查完全不可用: 1. 「验证」必然失败:只发 1 个 100ms 静音块就 finish-task,DashScope 对 <200ms 音频必返回 task-failed: EmptyAudio(2026-07 实测边界:100ms 拒、 200ms 起收)——有效凭据也永远显示「操作失败」。改为发送 500ms 静音。 2. 「拉取模型」假成功:直接返回硬编码列表、不发任何网络请求,Key/endpoint 全错也显示成功。现在先执行与「验证」相同的 WebSocket 连通性检查 (百炼无模型列表接口,列表本身仍为静态)。 3. 接口地址误填 https://(百炼控制台兼容模式/专属域名地址)时,WS 握手报的 "URL scheme not supported" 被前端兜底成笼统「操作失败」。现在验证入口 校验协议头必须为 ws:// / wss://,返回专用错误码 bailianEndpointSchemeInvalid,前端映射为含默认 wss 地址的明确提示 (en / zh-CN / zh-TW / ja / ko)。 测试:cargo test 555 passed;npm run build (tsc + vite) 通过; DashScope 线上协议行为已用独立脚本实测确认。
bailian.rs 头注释预留的 follow-up 协议线:/api-ws/v1/realtime,与经典
/api-ws/v1/inference 并列为独立供应商 bailian-qwen3-realtime。
- asr/qwen_realtime.rs:新客户端。base64 JSON 事件流 + server_vad 自动断句,
按序收集 completed 句段;session.finish 冲刷尾段后回 session.finished。
关键协议行为均经 2026-07 线上实测:尾段冲刷(说到一半松手不丢字)、
纯静音验证干净返回、language 省略走自动检测、业务空间专属域名
(wss://{WorkspaceId}.cn-beijing.maas.aliyuncs.com)同样承载此路径。
- coordinator / asr_wiring / dictation / qa_session / resources:与 Bailian
分支同构接线(流式 WS + DeferredAsrBridge)。
- 验证与拉取模型:真实 WS 连通性检查;协议头校验(qwen3EndpointSchemeInvalid)。
- 前端:ASR 预设下拉新增一项;i18n 5 语言。
测试:cargo test 573 passed(新增 18 个客户端单测);npm run build 通过。
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
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.
User description
摘要
Closes #774。依赖 #773(分支基于其之上,请先合并该 PR;本 PR 复用其引入的
endpoint_scheme_is_websocket校验)。实现
asr/bailian.rs头注释预留的 follow-up 协议线:Qwen3-ASR-Flash 实时版(OpenAI Realtime 风格 WebSocket,/api-ws/v1/realtime),作为独立供应商bailian-qwen3-realtime与经典 fun-asr-realtime 并列。业务空间专属域名(wss://{WorkspaceId}.cn-beijing.maas.aliyuncs.com)用户与受限工作空间 Key(仅授权 Qwen3 系模型)用户由此获得可用的实时通道。修复 / 新增 / 改进
asr/qwen_realtime.rs(新增,核心):Realtime 协议 client。base64 JSON 事件流(input_audio_buffer.append,3200B/100ms 块)+server_vad服务端自动断句;按到达顺序收集completed句段(CJK 直连、拉丁词间补空格);session.finish依赖服务端冲刷尾段后回session.finished。整体结构、并发模型(send worker + 弱引用 reader)、超时口径(5s 会话建立 / 12s 最终结果)与bailian.rs保持同构。language省略走服务端自动检测。coordinator/asr_wiring/dictation/qa_session/resources按 Bailian 分支同构接入(流式 WS +DeferredAsrBridge缓冲开链前音频),含听写、悬浮问答、重转录、取消全路径。qwen3EndpointSchemeInvalid(含默认 Realtime 地址的明确提示)。兼容
qwen3-asr-flash(兼容模式 chat/completions,另一条协议线)。bailian-qwen3-realtime,不改动任何现有供应商的行为、凭据格式与默认值。测试计划
cargo test --manifest-path src-tauri/Cargo.toml→ 573 passed / 0 failed(含新增 18 个 client 单测:URL 拼接/专属域名、消息构造、interimstash/text语义、completed 收集、尾段兜底、错误事件、静音空会话、句段拼接、音频缓冲)npm run build(tsc + vite)→ 通过session.finish尾段冲刷(含刻意截断音频尾部的场景)、静音会话、省略 language、专属域名全链路真实语音转写逐字正确。scripts/build-mac.sh本地构建安装):PR Type
Bug fix, Enhancement
Description
Added new ASR provider for Qwen3-ASR-Flash Realtime (OpenAI Realtime WS protocol)
Fixed bailian ASR connection check: increased silence duration and endpoint scheme validation
Updated frontend and i18n for new provider and error codes across 5 languages
Wired new provider into coordinator, dictation, and QA sessions
Diagram Walkthrough
File Walkthrough
2 files
Added WebSocket scheme validation helperAdded validation for Qwen3 and fixed bailian EmptyAudio10 files
Exported Qwen3RealtimeASR and credentialsImplemented Qwen3-ASR-Flash realtime WS clientAdded credential check for new Qwen3 realtime providerIntegrated Qwen3 realtime ASR into coordinatorAdded Qwen3 realtime ASR wiringAdded dictation session support for Qwen3 realtimeAdded QA session support for Qwen3 realtimeAdded cancel support for Qwen3 realtimeAdded preset entry for Bailian Qwen3 RealtimeAdded AsrPresetId for new provider5 files
Added i18n for new provider name and error messagesAdded i18n for new provider name and error messagesAdded i18n for new provider name and error messagesAdded i18n for new provider name and error messagesAdded i18n for new provider name and error messages