Skip to content

feat(asr): 新增百炼 Qwen3-ASR-Flash 实时供应商(OpenAI Realtime WS 协议)#775

Merged
H-Chris233 merged 2 commits into
Open-Less:betafrom
bigsongeth:feat/qwen3-asr-realtime
Jul 12, 2026
Merged

feat(asr): 新增百炼 Qwen3-ASR-Flash 实时供应商(OpenAI Realtime WS 协议)#775
H-Chris233 merged 2 commits into
Open-Less:betafrom
bigsongeth:feat/qwen3-asr-realtime

Conversation

@bigsongeth

@bigsongeth bigsongeth commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

User description

摘要

Closes #774。依赖的 #773 已合并;本分支已 rebase 到合并后的 beta(复用其引入的 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 保持同构。
  • 协议行为均经 2026-07 线上实测(公共网关 + 专属域名):尾段冲刷(说到一半松手不丢字)、纯静音验证干净返回、language 省略走服务端自动检测。
  • 接线coordinator / asr_wiring / dictation / qa_session / resources 按 Bailian 分支同构接入(流式 WS + DeferredAsrBridge 缓冲开链前音频),含听写、悬浮问答、重转录、取消全路径。
  • 连接检查:「验证」发 500ms 静音做真实会话检查;「拉取模型」先连通性检查再返回官方文档在案的模型列表(稳定别名 + 2 个快照版);协议头校验返回 qwen3EndpointSchemeInvalid(含默认 Realtime 地址的明确提示)。
  • 前端:ASR 供应商下拉新增「阿里云百炼 Qwen3 实时 ASR」预设;i18n 5 语言(en / zh-CN / zh-TW / ja / ko)。

兼容

  • 不包含:热词(Realtime 协议文档未提供 vocabulary 下发);手动 commit 模式(采用 server_vad,非 VAD 模式官方建议 ≤60s,不适合不限时长听写);批式 qwen3-asr-flash(兼容模式 chat/completions,另一条协议线)。
  • 对现有用户 / 本地环境 / 构建流程的影响:纯增量——新增供应商 id bailian-qwen3-realtime,不改动任何现有供应商的行为、凭据格式与默认值。

测试计划

  • 命令:cargo test --manifest-path src-tauri/Cargo.toml → 573 passed / 0 failed(含新增 18 个 client 单测:URL 拼接/专属域名、消息构造、interim stash/text 语义、completed 收集、尾段兜底、错误事件、静音空会话、句段拼接、音频缓冲)
  • 命令:npm run build(tsc + vite)→ 通过
  • 协议实测:独立 WebSocket 脚本直连线上验证 VAD 断句、session.finish 尾段冲刷(含刻意截断音频尾部的场景)、静音会话、省略 language、专属域名全链路真实语音转写逐字正确。
  • 手工验证(macOS 15 / Apple Silicon,scripts/build-mac.sh 本地构建安装):
    • 新预设选择后默认值正确填充;「验证」「拉取模型」通过。
    • 公共网关与业务空间专属域名两种 endpoint 均实测听写正常。
    • 多句带停顿听写断句拼接正常;说到一半立即松手尾段不丢。

PR Type

Enhancement


Description

  • New ASR provider for Qwen3-ASR-Flash realtime (OpenAI Realtime WS protocol).

  • Supports business space dedicated domain; validation with real connectivity check.

  • Frontend preset and i18n across 5 languages.


Diagram Walkthrough

flowchart LR
  A["Qwen3RealtimeASR client"] --> B["session.update (server_vad)"]
  B --> C["input_audio_buffer.append (base64)"]
  C --> D["server_vad auto-segmentation"]
  D --> E["conversation.item.input_audio_transcription.completed"]
  E --> F["session.finish flushes tail"]
  F --> G["session.finished -> RawTranscript"]
Loading

File Walkthrough

Relevant files
Enhancement
11 files
mod.rs
Export new Qwen3Realtime modules                                                 
+2/-0     
qwen_realtime.rs
New Qwen3-ASR-Flash realtime client                                           
+970/-0 
credentials.rs
Add credential check for new provider                                       
+3/-1     
providers.rs
Add model list and validation for Qwen3 realtime                 
+55/-0   
coordinator.rs
Wire new provider kind and re-transcribe                                 
+41/-2   
asr_wiring.rs
Add Qwen3Realtime variant to QaAsrStart                                   
+24/-0   
dictation.rs
Implement session start/end for Qwen3 realtime                     
+104/-0 
qa_session.rs
Handle Qwen3 realtime in overlay and end QA                           
+39/-0   
resources.rs
Add cancel support for Qwen3 realtime                                       
+1/-0     
ProvidersSection.tsx
Add preset for Qwen3 realtime ASR                                               
+5/-0     
shared.tsx
Add new provider ID to AsrPresetId                                             
+1/-0     
Documentation
5 files
en.ts
Add English i18n keys for new provider                                     
+2/-0     
ja.ts
Add Japanese i18n for Qwen3 realtime                                         
+2/-0     
ko.ts
Add Korean i18n for Qwen3 realtime                                             
+2/-0     
zh-CN.ts
Add Chinese (Simplified) i18n for new provider                     
+2/-0     
zh-TW.ts
Add Chinese (Traditional) i18n for new provider                   
+2/-0     

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit 711b2da)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

774 - Partially compliant

Compliant requirements:

  • 新增独立 ASR 供应商,包含专有协议 client (asr/qwen_realtime.rs) 和 provider kind (bailian-qwen3-realtime),默认 endpoint 和模型正确,支持业务空间专属域名。
  • 验证函数 (validate_qwen3_realtime_asr_provider) 执行真实 WebSocket 连通性检查和协议头校验(wss://),与 bailian 修复后的逻辑一致。
  • 拉取模型函数 (list_provider_models) 先执行连通性检查再返回静态列表。
  • 未替换或移除原有的 fun-asr-realtime 供应商。

Non-compliant requirements:

(none)

Requires further human verification:

(none)

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 Security concerns

Minor:
The open_session method does not validate the endpoint scheme (wss://) itself; it relies on the calling validation function (validate_qwen3_realtime_asr_provider) to do so. If the ASR is used programmatically without going through validation, an insecure ws:// endpoint could be accepted. Since the PR wraps the validation tightly in the provider wiring, this is low risk, but adding a scheme guard in open_session itself would be more robust.

⚡ No major issues detected

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 通过。
@bigsongeth bigsongeth force-pushed the feat/qwen3-asr-realtime branch from 0641aa7 to ab10692 Compare July 10, 2026 16:55
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit ab10692

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 711b2da

@H-Chris233 H-Chris233 merged commit 9ed34da into Open-Less:beta Jul 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[asr] 新增百炼 Qwen3-ASR-Flash 实时供应商(OpenAI Realtime WS 协议),支持业务空间专属域名

2 participants