Skip to content

fix(asr): 百炼连接检查修复验证必败(EmptyAudio)并真实校验连通性与协议头#773

Open
bigsongeth wants to merge 1 commit into
Open-Less:betafrom
bigsongeth:fix/bailian-asr-tools-ux
Open

fix(asr): 百炼连接检查修复验证必败(EmptyAudio)并真实校验连通性与协议头#773
bigsongeth wants to merge 1 commit into
Open-Less:betafrom
bigsongeth:fix/bailian-asr-tools-ux

Conversation

@bigsongeth

@bigsongeth bigsongeth commented Jul 10, 2026

Copy link
Copy Markdown

User description

摘要

Fixes #772

「阿里云百炼实时 ASR」的连接检查此前完全不可用:「验证」对有效凭据也必然失败(EmptyAudio),「拉取模型」不发网络请求永远假成功,接口地址填错协议头时只报笼统「操作失败」。本 PR 修复验证必败的根因,并让两颗按钮的语义与其他厂商对齐。

修复 / 新增 / 改进

  • 验证必败修复(根因):validate_bailian_asr_provider 原来只发 1 个 100ms 静音块,DashScope 对 <200ms 音频固定返回 task-failed: EmptyAudio(2026-07 实测边界:单帧 100ms 拒、200ms 起收)。改为发送 500ms 静音(5×TARGET_AUDIO_CHUNK_BYTES),与 Mimo 验证的 250ms 同量级。
  • list_provider_models 的 bailian 分支在返回静态列表前先执行与「验证」相同的 WebSocket 连通性检查(百炼无模型列表 HTTP 接口,列表仍为静态,但失败路径不再被吞掉)。
  • 验证前校验接口地址协议头必须为 ws:// / wss://,否则返回 bailianEndpointSchemeInvalid 错误码;新增 endpoint_scheme_is_websocket 帮助函数与单元测试;前端 + i18n×5(en / zh-CN / zh-TW / ja / ko)映射为含默认 wss 地址的明确提示。

兼容

  • 不包含:xiaomi-mimo-asr 的「拉取模型」同样是硬编码假成功(同类残留,未在本 PR 展开);听写运行时路径不变(真实语音远超 200ms,不受 EmptyAudio 影响)。
  • 对现有用户 / 本地环境 / 构建流程的影响:凭据格式、默认值、协议实现均未变。行为变化仅在设置页「连接检查」:验证从必败变为如实反映凭据状态;拉取模型从必成功变为凭据错误时如实报错。

测试计划

  • 命令:cargo test --manifest-path src-tauri/Cargo.toml → 555 passed / 0 failed
  • 命令:npm run build(tsc + vite)→ 通过
  • 协议行为:独立 WebSocket 脚本对 DashScope 线上实测——单帧 100ms 静音 → task-failed: EmptyAudio;200/300/500/1000ms → task-finishedhttps:// 地址 → 握手 "URL scheme not supported"。
  • 手工验证(macOS 15 / Apple Silicon,scripts/build-mac.sh 本地构建安装):
    • 有效 Key + 默认 wss 地址 → 验证通过(正式版 1.3.14 上同配置必失败);拉取模型成功。
    • 接口地址填 https://...maas.aliyuncs.com... → 显示"接口地址必须以 wss:// 开头"明确提示。
    • 错误 Key → 验证 / 拉取模型均如实报错。
    • 正常听写不受影响。

PR Type

Bug fix, Enhancement


Description

  • Fixed validation always failing (EmptyAudio) by sending 500ms silence.

  • Added real WebSocket connectivity check to "list provider models".

  • Validated endpoint scheme (ws:///wss://) and returned specific error.

  • Added i18n and frontend mapping for new error code across 5 languages.


Diagram Walkthrough

flowchart LR
  A["Validate / List Models"] --> B{"Endpoint starts with ws:// or wss://?"};
  B -- No --> C["Return bailianEndpointSchemeInvalid error"];
  B -- Yes --> D["Send 500ms silence (5 chunks)"];
  D --> E["WebSocket connectivity check"];
  E -- Success --> F["Return model list (static)"];
  E -- Failure --> G["Return error from provider"];
Loading

File Walkthrough

Relevant files
Enhancement
2 files
bailian.rs
Added endpoint_scheme_is_websocket helper and test             
+27/-0   
ProvidersSection.tsx
Mapped new error code to translated message                           
+1/-0     
Bug fix
1 files
providers.rs
Fixed validation interval and added scheme check                 
+15/-1   
Documentation
5 files
en.ts
Added bailianEndpointSchemeInvalid error message                 
+1/-0     
ja.ts
Added bailianEndpointSchemeInvalid in Japanese                     
+1/-0     
ko.ts
Added bailianEndpointSchemeInvalid in Korean                         
+1/-0     
zh-CN.ts
Added bailianEndpointSchemeInvalid in Chinese (Simplified)
+1/-0     
zh-TW.ts
Added bailianEndpointSchemeInvalid in Chinese (Traditional)
+1/-0     

三个缺陷叠加导致「阿里云百炼实时 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 线上协议行为已用独立脚本实测确认。
@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

772 - Partially compliant

Compliant requirements:

  • "验证"发送≥200ms(实际500ms)的静音,有效凭据下返回成功。
  • "拉取模型"在返回静态列表前执行真实连通性检查,凭据错误时如实报错。
  • 非 ws:// / wss:// 协议头的接口地址返回专门错误码,前端显示含默认 wss 地址的明确提示,覆盖全部5种语言。

Non-compliant requirements:

  • xiaomi-mimo-asr的"拉取模型"硬编码列表未在本PR中修复(如 ticket 所述,可另立)。
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

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] 百炼「验证」必然失败(EmptyAudio);「拉取模型」硬编码假成功;https 地址只报笼统「操作失败」

1 participant