Skip to content

feat(asr): 接入通义千问/SiliconFlow/智谱 GLM 与国外常见 ASR 作为可选项 #212

Description

@appergb

背景

目前 coordinator.rs 只路由两条 ASR:

  • volcengine — 火山 SAUC bigmodel,自建 WebSocket(asr/volcengine.rs
  • whisperWhisperBatchASRasr/whisper.rs),任意 OpenAI 兼容 POST /audio/transcriptions,凭据走 asr.api_key / asr.endpoint / asr.model

设置页 Settings.tsx:279ASR_PRESETS 也只列了这两项。Issue #58 中曾尝试加入 SiliconFlow,因后端未路由被回退(注释见 Settings.tsx:277)。

目标

把以下 ASR 服务商作为新的可选项接入,复用 OpenAI 兼容批处理通道,让用户在「设置 → 服务商 → ASR」中通过下拉切换、自动预填 baseURL/model:

服务商端点推荐模型兼容性
通义千问(阿里 DashScope)https://dashscope.aliyuncs.com/compatible-mode/v1qwen3-asr-flashOpenAI 兼容(待复核)
硅基流动 SiliconFlowhttps://api.siliconflow.cn/v1FunAudioLLM/SenseVoiceSmallOpenAI 兼容 ✅
智谱 GLMhttps://open.bigmodel.cn/api/paas/v4glm-asr-2512OpenAI 兼容 ✅
OpenAI Whisperhttps://api.openai.com/v1whisper-1 / gpt-4o-transcribe已支持(现有 whisper preset)
Groqhttps://api.groq.com/openai/v1whisper-large-v3-turboOpenAI 兼容 ✅

设计原则

  1. 后端零侵入或最小侵入:能用现有 WhisperBatchASR 通道的,就不新增 Rust 模块——「采用标准接口形式」即 OpenAI /audio/transcriptions
  2. 凭据隔离:用现有 asr.api_key / asr.endpoint / asr.model 三个 CredentialAccount,切换 preset 时由前端把 asr.endpointasr.model 默认值填上(参考 LLM preset 切换逻辑)。
  3. 失败保护沿用既有契约:CLAUDE.md 明确 ASR fallback 是静默的——凭据缺失走 mock 占位,不抛硬错。新 preset 必须遵循。
  4. 不引入流式实现:通义/SiliconFlow/GLM 等的批处理已能满足 OpenLess 的 hold-to-talk 模型;如果未来要 Aliyun NLS Paraformer 的真流式 / Deepgram / AssemblyAI(非 OpenAI 兼容),单独开 issue。

V1 实施清单(本 issue 范围)

Frontend(openless-all/app/src/pages/Settings.tsx

  • 扩展 ASR_PRESETS:新增 qwen / siliconflow / zhipu / groq 四项;保留 whisper(OpenAI 原生)。
  • 切换 preset 时自动写 asr.endpointasr.model 默认值(onAsrProviderChange 中加 preset 表)。
  • i18n:在 i18n/zh-CN.tsi18n/en.tssettings.providers.presets.* 节点补对应文案。

Backend(仅扩枚举,不新增 ASR 客户端

  • coordinator.rs:906if active_asr == \"whisper\" 分支扩成 "任意非 volcengine 都走 WhisperBatchASR";或显式列入 qwen / siliconflow / zhipu / groq
  • read_whisper_credentialsmodel fallback 保留 whisper-1,但当 base_url 是非 OpenAI 时不强制——前端 preset 已经塞入正确 model。

验证(CLAUDE.md 要求逐项实测)

  • 切换至 SiliconFlow(API key 自备),录一段中文,capsule → polish → insertion 全链路通过
  • 切换至 Qwen3-ASR-Flash(DashScope key 自备),同上
  • 切换至 GLM-ASR(智谱 key 自备),同上
  • 凭据缺失时不抛硬错(fallback 静默契约)
  • 凭据从 Volcengine 切换到 Whisper preset 后再切回去,UI 状态正确

待复核风险

  • DashScope 是否真的对 Qwen3-ASR-Flash 暴露 OpenAI /audio/transcriptions:阿里 help 中心 JS 渲染,curl 抓不到正文;实施前需先 curl 一发 16 kHz mono WAV 验证,若不兼容则 Qwen 这一项落到 V2(单独客户端)。
  • 采样率WhisperBatchASR 固定写 16 kHz mono PCM → WAV,理论上各家都接受,但 DashScope/SiliconFlow 个别模型可能需要 16 kHz 以上;先按 16 kHz 试,失败再加配置。

不在范围(V2 候选,单独提 issue)

  • Aliyun NLS Paraformer 真流式(WebSocket)—— 需要新 Rust 模块,工作量与 volcengine 客户端相当
  • Deepgram /v1/listen、AssemblyAI 上传+轮询 —— 非 OpenAI 兼容,需独立客户端
  • 与 Issue feat(ASR): 增加对本地 ASR AI 的支持 #211(本地 ASR)协调统一抽象层

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions