fix(asr): 百炼连接检查修复验证必败(EmptyAudio)并真实校验连通性与协议头#773
Open
bigsongeth wants to merge 1 commit into
Open
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 线上协议行为已用独立脚本实测确认。
4 tasks
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
摘要
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 failednpm run build(tsc + vite)→ 通过task-failed: EmptyAudio;200/300/500/1000ms →task-finished;https://地址 → 握手 "URL scheme not supported"。scripts/build-mac.sh本地构建安装):https://...maas.aliyuncs.com...→ 显示"接口地址必须以 wss:// 开头"明确提示。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"];File Walkthrough
2 files
Added endpoint_scheme_is_websocket helper and testMapped new error code to translated message1 files
Fixed validation interval and added scheme check5 files
Added bailianEndpointSchemeInvalid error messageAdded bailianEndpointSchemeInvalid in JapaneseAdded bailianEndpointSchemeInvalid in KoreanAdded bailianEndpointSchemeInvalid in Chinese (Simplified)Added bailianEndpointSchemeInvalid in Chinese (Traditional)