Skip to content

feat(asr): 百炼 ASR 支持 fun-asr-flash 并统一三协议为单一入口#793

Open
bigsongeth wants to merge 1 commit into
Open-Less:betafrom
bigsongeth:feat/bailian-asr-unify
Open

feat(asr): 百炼 ASR 支持 fun-asr-flash 并统一三协议为单一入口#793
bigsongeth wants to merge 1 commit into
Open-Less:betafrom
bigsongeth:feat/bailian-asr-unify

Conversation

@bigsongeth

@bigsongeth bigsongeth commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

User description

摘要

让阿里云百炼(DashScope)三种 ASR 协议都能用、并收成一个用户入口。

百炼同一厂商、同一把 key 下有三种互不兼容的线协议:

模型 协议 网关 形态
fun-asr-realtime 经典实时 WS(run-task/finish-task 双工 + PCM 帧) …/api-ws/v1/inference/ 边说边出
qwen3-asr-flash-realtime OpenAI-Realtime 风格 WS …/api-ws/v1/realtime 边说边出
fun-asr-flash multimodal-generation HTTP 批量(POST JSON,URL/base64) …/multimodal-generation/generation 说完整段转

此前只有前两个,且各是独立 provider、独立 key;fun-asr-flash 是唯一的 HTTP 批量协议,现有两条 WS 通道都接不了 → 用不了。本 PR 补齐第三条通道,并把三条收成一个「阿里云百炼」入口、按模型名自动路由协议。

修复 / 新增 / 改进

  • 新增 asr/dashscope_multimodal.rs:multimodal-generation 批量 ASR 客户端(攒 PCM → WAV → base64 → POST → 多路径兜底解析响应),复用 mimo 的分片/CJK 拼接。
  • 分发重构:ASR provider 分类收敛为 ActiveAsrProviderKind 单一来源,preflight_credential / configured_fields 等改为穷尽 match(去掉静默 else 兜底),新增通道时编译器强制补齐各分发点,消除「装完才发现某处漏了」。
  • 统一入口:UI 三条百炼收成一个「阿里云百炼」+ 模型框(可「拉取模型」或手填任意 DashScope ASR 模型),后端 resolve_effective_asr_provider(model) 按模型名把 build / 验证 路由到对应协议,endpoint 按协议自动推导;模型框下加实时 / 录音文件协议提示。

兼容

  • 不包含:移动端 / Android 相关改动;不改版本号。
  • 对现有用户:
    • bailian(fun-asr-realtime)用户无感,默认仍走经典实时;
    • bailian-qwen3-realtime 保留为隐藏别名,老配置照常工作(下拉仅对已在用者显示);
    • bailian-fun-asr-flash 为本 PR 新增(此前无用户);
    • 行为变化(需知会):统一入口下 qwen3 / fun-asr-flash 的 endpoint 一律用协议默认地址、忽略共用存储值——业务空间专属域名的高级用户在统一入口暂不能自定义 endpoint(仍可经隐藏别名 id 路径覆盖)。
  • 构建 / 本地环境:mimo 的 split_pcm_by_duration / join_transcript_chunks 提为 pub(crate) 供复用(零行为改动);无新增依赖。

测试计划

  • 命令:cargo test --lib → 结果:610 passed(对 beta 基线);新增 resolve_effective_asr_provider / preflight_credential / configured_fields / dashscope 客户端等单测。
  • 命令:cargo check(macOS native)+ 前端 tsc(npm run build)→ 均通过(对 beta 基线);跨平台 Android/Win/Linux 未加 cfg 分支,交 CI 确认。
  • 真机 API:fun-asr-flash-2026-06-15 multimodal-generation(URL 与 base64 两种输入)→ HTTP 200、转写正确、~600ms。
  • in-app 三协议听写冒烟(实时经典 / qwen3 / fun-asr-flash 各验证 + 听写)→ macOS 本地重装后手测通过。

PR Type

Enhancement, Tests


Description

  • Add fun-asr-flash batch ASR via multimodal-generation HTTP API

  • Refactor provider dispatch to ActiveAsrProviderKind enum with exhaustive match

  • Unify three Bailian ASR protocols into a single UI entry with automatic model routing

  • Add i18n and model type hints for realtime vs recorded-file modes


Diagram Walkthrough

flowchart LR
  A["User selects model"] --> B["Model route: fun-asr-realtime?"]
  A --> C["Model route: qwen3-asr-flash-realtime?"]
  A --> D["Model route: fun-asr-flash*?"]
  B --> E["BailianRealtimeASR (WS)"]
  C --> F["Qwen3RealtimeASR (WS)"]
  D --> G["DashScopeMultimodalASR (HTTP batch)"]
Loading

File Walkthrough

Relevant files
Enhancement
8 files
dashscope_multimodal.rs
Add new HTTP batch ASR client for fun-asr-flash                   
+405/-0 
mod.rs
Export new DashScopeMultimodalASR module                                 
+2/-0     
providers.rs
Add validation and model listing for unified Bailian ASR 
+112/-10
coordinator.rs
Add DashScopeMultimodal variant and model routing logic   
+208/-10
dictation.rs
Route session start for new batch ASR provider                     
+58/-4   
qa_session.rs
Handle DashScopeMultimodal in QA sessions                               
+29/-0   
resources.rs
Add cancel support for new ASR variant                                     
+1/-0     
ProvidersSection.tsx
Unify three Bailian entries and add protocol hints             
+64/-42 
Refactoring
5 files
mimo.rs
Make split and join functions pub(crate) for reuse             
+6/-2     
credentials.rs
Refactor credentials check using ActiveAsrProviderKind     
+16/-13 
asr_wiring.rs
Refactor build and credential check for new provider kind
+40/-20 
Overview.tsx
Use ASR_PRESETS for provider name mapping                               
+6/-13   
shared.tsx
Extract ASR_PRESETS as single source of truth                       
+42/-16 
Documentation
5 files
en.ts
Add translation keys for unified Bailian ASR                         
+3/-0     
ja.ts
Add Japanese translation for new ASR entry                             
+3/-0     
ko.ts
Add Korean translation for new ASR entry                                 
+3/-0     
zh-CN.ts
Add Chinese translation for unified Bailian ASR                   
+3/-0     
zh-TW.ts
Add Traditional Chinese translation for new ASR entry       
+3/-0     

@github-actions

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ 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.

1 participant