Skip to content

feat(asr): 接入阶跃星辰 StepAudio 2.5 批式转写,词典走一等 hotwords - #835

Merged
H-Chris233 merged 4 commits into
Open-Less:betafrom
bigsongeth:feat/stepfun-asr
Jul 18, 2026
Merged

feat(asr): 接入阶跃星辰 StepAudio 2.5 批式转写,词典走一等 hotwords#835
H-Chris233 merged 4 commits into
Open-Less:betafrom
bigsongeth:feat/stepfun-asr

Conversation

@bigsongeth

@bigsongeth bigsongeth commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

User description

概要

接入阶跃星辰(StepFun)StepAudio 2.5 ASR 作为一等供应商。它的 /v1/audio/transcriptions 是标准 OpenAI multipart 形状,归入现有 Whisper 兼容路由即可——无新协议客户端,改动集中在 preset 注册和两个小适配。

改动

  • 前端ASR_PRESETS 新增 stepfunhttps://api.stepfun.com/v1 + stepaudio-2.5-asr),i18n 五语言补齐。
  • 词典 → 一等 hotwords:实测 StepFun 静默忽略 prompt(200 但不参与偏置),词汇偏置要走它专门的 hotwords 参数(可解析的 JSON 数组字符串)。WhisperBatchASR 新增 with_hotwords builder(沿用 with_request_format 的模式),wiring 按 whisper_uses_hotwords 在 prompt / hotwords 间二选一路由,QA 与听写两处构造点共用 whisper_vocab_for_provider
  • verbose_json 保持关闭:StepFun response_format 只认 json/text,发 verbose_json 会 400(照 siliconflow / zhipu 先例)。
  • 修「验证」按钮的静音假阴性:验证探针是 250ms 纯静音,StepFun 对无语音内容直接 400 "no speech found"——但能走到内容拒收说明鉴权(错 key 是 401)和模型名(错模型是 404 model_invalid)都已通过、转写管线是通的。现在把这类 400 判为验证成功,不再对静音敏感的厂商恒报假阴性。匹配措辞刻意收窄(仅 no speech),宁可漏判也不把真正的参数错误误判成功。

实测矩阵(真实 StepFun key 逐项打点,2026-07-16)

请求 结果
真实语音 + response_format=json / 缺省 / 带 prompt / 带 hotwords ✅ 200,转写准确
response_format=verbose_json ❌ 400 only support json,text
250ms 静音(验证探针形状) ❌ 400 no speech found
错 key / 错模型名 401 / 404(与验证成功路径可区分)
延迟 5.5s 音频 ≈ 0.95s 往返(三次 0.92–1.01s)
GET /v1/models(拉取模型按钮) ✅ OpenAI 形状,含 stepaudio-2.5-asr 等 6 个 asr 模型

测试

  • asr::whisper::tests::hotwords_sent_as_json_array_field_without_prompt(本地 TCP 服务器断言 multipart 含 hotwords JSON 数组、不含 prompt、空白词条被过滤)
  • coordinator::tests::stepfun_is_whisper_compatible_with_hotwords_vocab(路由/格式/切分/词典二选一契约)
  • commands::providers::tests::silence_probe_content_rejection_is_not_a_credential_error
  • 存量 whisper(34)/ providers(12)套件全绿;tsc --noEmit / cargo check 通过。

后续(不在本 PR)

stepaudio-2.5-asr-stream 走 OpenAI Realtime 风格 WS(input_audio_buffer.append 事件族,与 qwen_realtime.rs 同源),如需边说边出字可照百炼先例在同一 stepfun 入口下按模型名二次路由;批式 0.15 元/时 vs 流式 1.2 元/时,听写场景批式已足够(松手 ~1s 上屏)。

🤖 Generated with Claude Code


PR Type

Enhancement


Description

  • Add StepFun StepAudio 2.5 ASR support

  • Realtime WebSocket client (stepfun_realtime.rs)

  • Batch ASR via Whisper-compatible endpoint with hotwords

  • One-entry dual-protocol routing (model suffix -stream)

  • Frontend preset and i18n, validation fix for silence probe


Diagram Walkthrough

flowchart LR
  stepfun_preset["StepFun Preset"] --> resolve["resolve_effective_asr_provider"]
  resolve -- "model='*-stream'" --> rt_client["StepfunRealtimeASR (WS)"]
  resolve -- "else" --> batch_client["WhisperBatchASR (multipart)"]
  batch_client --> hotwords["hotwords (JSON array)"]
  rt_client --> prompt["prompt (session.update)"]
Loading

File Walkthrough

Relevant files
Enhancement
9 files
mod.rs
Register stepfun_realtime module                                                 
+2/-0     
stepfun_realtime.rs
Add StepFun realtime WS ASR client                                             
+1089/-0
whisper.rs
Add hotwords builder and encoding                                               
+82/-0   
providers.rs
Route StepFun validation to realtime or batch                       
+83/-2   
coordinator.rs
Add StepfunRealtime variant and routing logic                       
+109/-1 
asr_wiring.rs
Wire StepFun with hotwords and dual protocol                         
+63/-6   
dictation.rs
Integrate StepFun realtime into dictation flow                     
+115/-3 
qa_session.rs
Handle StepFun realtime in QA session end                               
+39/-0   
resources.rs
Cancel StepFun realtime in resource cleanup                           
+1/-0     
Refactoring
1 files
qwen_realtime.rs
Make join_segments pub(crate) for reuse                                   
+2/-1     
I18n
5 files
en.ts
Add English i18n for StepFun preset                                           
+1/-0     
ja.ts
Add Japanese i18n for StepFun preset                                         
+1/-0     
ko.ts
Add Korean i18n for StepFun preset                                             
+1/-0     
zh-CN.ts
Add Chinese (Simplified) i18n for StepFun                               
+1/-0     
zh-TW.ts
Add Chinese (Traditional) i18n for StepFun                             
+1/-0     
Configuration
1 files
shared.tsx
Add StepFun ASR preset definition                                               
+6/-0     

StepFun 的 /v1/audio/transcriptions 是标准 OpenAI multipart(实测 2026-07),
归入 Whisper 兼容路由即可,无需新协议客户端:

- 前端新增 stepfun preset(https://api.stepfun.com/v1 + stepaudio-2.5-asr),
  i18n 五语言补齐;
- StepFun 静默忽略 prompt(实测返回 200 但不参与偏置),词汇偏置走专门的
  hotwords 参数(JSON 数组字符串)——WhisperBatchASR 新增 with_hotwords,
  wiring 按 whisper_uses_hotwords 在 prompt / hotwords 间二选一路由,
  用户词典在 StepFun 下才真正生效;
- response_format 只认 json/text → verbose_json 幻听过滤保持关闭;
- 修「验证」按钮对静音敏感厂商的假阴性:探针是 250ms 纯静音,StepFun 返回
  400 "no speech found",但走到内容拒收说明鉴权(错 key=401)与模型名
  (错模型=404)均已通过——判为验证成功而非凭据错误。

实测矩阵(真实 key 逐项打点):真实语音+json/缺省/带 prompt/带 hotwords 均
200 且转写准确(5.5s 音频约 0.95s 往返);verbose_json 400;静音 400
no speech;错 key 401;错模型 404。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit 1a91d88)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

照百炼「一个入口、按模型二次路由」的先例:stepfun preset 下模型填
`stepaudio-2.5-asr-stream`(或任意 `*-stream`)即走新的实时 WS 客户端
(asr/stepfun_realtime.rs),其余模型维持批式 Whisper 兼容路径。凭据与
「已配置」判定仍看真实 active `stepfun`,一把 key、同一个 https base
(wss URL 由 client 自动派生)。

协议与 qwen_realtime 同为 OpenAI Realtime 风格,但四处关键差异
(2026-07-16 真实接口逐项实测确认):

- 模型在 session.update 里传(session.audio.input.transcription.model),
  session 配置是 audio.input.{format,transcription,turn_detection} 嵌套形状;
- delta 的 text/stash 是「已确定前缀 + 未定尾巴」的拼接关系(Qwen 是互斥取一);
- 没有服务端结束事件:session.finish 回 transcript.response.error,server_vad
  下 commit 被静默忽略。收尾靠客户端状态机:松手时冲刷尾音频 + 补送 700ms
  静音帧逼 VAD 关段,finishing && open_segments==0 即完成;纯静音会话由
  1.2s 宽限期兜底空文本成功(验证按钮复用该路径,全程 ~2s);
- 实时协议词汇偏置走 transcription.prompt(批式恰相反只认 hotwords),
  词典按 effective 协议自动选通道。

真机端到端(真实 key、模拟 recorder 时序):session 建立 186ms,
松手→最终结果 251ms(批式 ~950ms),5.5s 中文语音转写一字不差,
多句段 VAD 断句由 join_segments 复用 qwen 拼接规则。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@bigsongeth bigsongeth changed the title feat(asr): 接入阶跃星辰 StepAudio 2.5 批式转写,词典走一等 hotwords feat(asr): 接入阶跃星辰 StepAudio 2.5(批式 + 流式实时,一入口双协议) Jul 16, 2026
@github-actions github-actions Bot changed the title feat(asr): 接入阶跃星辰 StepAudio 2.5(批式 + 流式实时,一入口双协议) feat(asr): 接入阶跃星辰 StepAudio 2.5 批式转写,词典走一等 hotwords Jul 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 4fae410

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit fa06797

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 1a91d88

@H-Chris233
H-Chris233 merged commit 17fe67c into Open-Less:beta Jul 18, 2026
5 checks passed
@bigsongeth
bigsongeth deleted the feat/stepfun-asr branch July 22, 2026 10:56
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.

2 participants