Skip to content

feat(asr): 新增 ElevenLabs Scribe 语音转录供应商 - #797

Closed
Billmvp73 wants to merge 6 commits into
Open-Less:betafrom
Billmvp73:build/elevenlabs-macos
Closed

Billmvp73 wants to merge 6 commits into
Open-Less:betafrom
Billmvp73:build/elevenlabs-macos

Conversation

@Billmvp73

@Billmvp73 Billmvp73 commented Jul 13, 2026 •

Copy link
Copy Markdown

User description

摘要

Fixes #795。

新增 ElevenLabs Scribe v2 批式语音转录供应商。ElevenLabs 使用 xi-api-key 请求头和 /v1/speech-to-text multipart 协议,不能直接复用现有 Whisper-compatible client,因此本 PR 增加独立 client,并接入 OpenLess 已有的 ASR 生命周期。

修复 / 新增 / 改进

  • 新增 asr/elevenlabs.rs:将 16 kHz mono PCM 编码为 WAV,并通过官方 multipart API 提交 model_id、音频文件和 tag_audio_events=false。
  • 默认 endpoint 为 https://api.elevenlabs.io/v1,默认模型为 scribe_v2;支持用户自定义 endpoint/model。
  • 自定义 endpoint 必须使用 HTTPS;仅为本地开发保留 loopback HTTP。请求禁止自动跟随重定向,避免向其他目标转发 xi-api-key 或音频。服务端错误只展示 HTTP 状态和本地白名单错误码,不回显不受信任的响应正文。
  • 覆盖普通听写、悬浮问答、历史重转录、取消、凭据检查、连接验证和 provider dispatch。
  • 设置页新增 ElevenLabs 预设,并补齐 en / zh-CN / zh-TW / ja / ko 的供应商名称。
  • 新增请求格式、单/多声道响应解析、空缓冲、provider-kind dispatch 等回归测试。

兼容

  • 不包含:Scribe v2 Realtime WebSocket、keyterm prompting、entity detection、speaker diarization 等高级能力。
  • 不包含:本地开发构建的 ad-hoc 签名、Keychain 权限弹窗或安装流程变更。
  • 对现有用户 / 本地环境 / 构建流程的影响:纯增量;不修改其他 ASR provider 的默认值、凭据格式或行为。远程自定义 endpoint 若仍使用明文 HTTP,需要迁移到 HTTPS。
  • 隐私与凭据:音频会发送到用户配置的 ElevenLabs endpoint;API key 继续通过 OpenLess 现有凭据存储读取,不进入源码或日志。本 PR、Issue 和测试证据均不包含真实 API key、请求凭据、request ID、原始音频或用户转录内容。

测试计划

  • 命令:cargo test --manifest-path src-tauri/Cargo.toml
    • 结果:608 passed / 0 failed。
  • 命令:npm run build
    • 结果:通过;保留仓库既有的 Rollup circular chunk warning,无新增构建失败。
  • 命令:cargo check --manifest-path src-tauri/Cargo.toml
    • 结果:通过;仅有仓库既有 warning。
  • 命令:git diff --check upstream/beta...HEAD
    • 结果:通过。
  • macOS Apple Silicon release build、安装和启动。
    • 结果:通过。
  • 真实端到端验证:macOS 录音 → ElevenLabs Scribe v2 转录 → 润色 → 当前应用插入。
    • 结果:通过;公开证据只保留脱敏结果摘要。

证据路径:PR Checks。

AI 使用披露

本实现与 Issue/PR 文档整理使用了 Codex/AI 辅助;提交者已人工审阅代码,并在 macOS 上完成构建和真实语音全链路验证。


PR Type

Enhancement, Tests, Documentation


Description

  • New ElevenLabs Scribe batch ASR client

  • Full wiring: dictation, QA, retranscribe, cancel, validation

  • SSRF validation extracted to endpoint_security module

  • Per-provider credential scoping via optional provider parameter

  • Frontend preset, upload notice, and i18n for 5 languages

  • Unit tests for client, provider dispatch, and SSRF checks


Diagram Walkthrough

flowchart LR
    AudioBuffer --> ElevenLabsClient
    ElevenLabsClient --> EncodeWav[Encode WAV]
    EncodeWav --> MultipartForm[Multipart POST]
    MultipartForm --> SecCheck[SSRF Check & Redirect Block]
    SecCheck --> ElevenLabsAPI
    ElevenLabsAPI --> ParseResponse[Parse JSON]
    ParseResponse --> Transcript
    Transcript --> App
Loading

File Walkthrough

Relevant files
Enhancement
15 files
elevenlabs.rs
New ElevenLabs Scribe ASR client                                                 
+531/-0 
mod.rs
Export ElevenLabs module                                                                 
+2/-0     
credentials.rs
Add provider-scoped credential read/write                               
+32/-4   
providers.rs
Add ElevenLabs provider validation                                             
+53/-11 
coordinator.rs
Integrate ElevenLabs ASR into coordinator                               
+43/-84 
asr_wiring.rs
Add ElevenLabs provider detection and QA start                     
+11/-0   
dictation.rs
Handle ElevenLabs dictation sessions                                         
+36/-0   
qa_session.rs
Handle ElevenLabs QA transcription                                             
+61/-0   
resources.rs
Add ElevenLabs cancel support                                                       
+1/-0     
endpoint_security.rs
Shared SSRF validation module                                                       
+109/-0 
lib.rs
Register endpoint_security module                                               
+1/-0     
credentials.rs
Add per-provider credential methods                                           
+22/-0   
asr-credentials.ts
Update credential IPC for provider scope                                 
+4/-4     
ProvidersSection.tsx
Add ElevenLabs preset, notice, per-provider fields             
+31/-17 
shared.tsx
Add ElevenLabs ASR preset definition                                         
+1/-0     
Documentation
5 files
en.ts
Add English i18n for ElevenLabs                                                   
+5/-3     
ja.ts
Add Japanese i18n for ElevenLabs                                                 
+5/-3     
ko.ts
Add Korean i18n for ElevenLabs                                                     
+5/-3     
zh-CN.ts
Add Simplified Chinese i18n for ElevenLabs                             
+5/-3     
zh-TW.ts
Add Traditional Chinese i18n for ElevenLabs                           
+5/-3     

@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit c26dfa7)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

795 - Fully compliant

Compliant requirements:

  • 新增独立 elevenlabs ASR provider,使用官方 xi-api-key + multipart Speech-to-Text 协议。
  • 默认 endpoint 为 https://api.elevenlabs.io/v1,默认模型为 scribe_v2,并允许用户自定义 endpoint/model。
  • 覆盖普通听写、QA、重转录和取消路径。
  • 设置页提供 ElevenLabs 预设,并补齐 en / zh-CN / zh-TW / ja / ko 的供应商名称。
  • API key 仅通过现有凭据存储读取,不进入日志、错误证据或仓库。
  • Rust 单测、前端构建、cargo check 和上游多平台 CI 通过(代码中包含了相关单元测试)。
  • 至少完成一次真实 macOS 全链路语音验证,PR 描述中提及已验证。
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

Billmvp73 and others added 4 commits July 13, 2026 00:32
Add ElevenLabs Speech-to-Text (Scribe) as a batch ASR provider.

ElevenLabs uses `POST /v1/speech-to-text` with multipart/form-data
(`model_id` + `file`) and the `xi-api-key` header — not OpenAI's Bearer
`/audio/transcriptions` protocol — so it gets a dedicated client
(`asr/elevenlabs.rs`) modeled on the MiMo batch client rather than riding
on WhisperBatchASR. `tag_audio_events=false` keeps bracketed non-speech
events out of dictation transcripts.

Wiring:
- ActiveAsr::ElevenLabs + ActiveAsrProviderKind::ElevenLabs, dictation /
  QA / retranscribe transcribe arms, cancel arm, credential reader.
- provider validation + model list (scribe_v1 / scribe_v2).
- credentials "configured" check (api key + endpoint + model).
- frontend preset, Overview label, en/zh-CN/zh-TW/ja/ko i18n.

Verified the wire protocol end-to-end against the live ElevenLabs API.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
scribe_v1 is deprecated and is removed from the ElevenLabs API on
2026-07-09, so shipping it as the default would break shortly. scribe_v2
is the current recommended model (higher accuracy, 99 languages, ~40%
cheaper, multi-language in one file). Update the Rust DEFAULT_MODEL, the
frontend preset, and the validation/model-list fallback accordingly;
keep scribe_v1 selectable in the model list for now.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
active_asr_provider_kind's test locked bailian/whisper/mimo/volcengine
but not ElevenLabs, so a regression in is_elevenlabs_provider or its
ordering in the dispatch chain would go uncaught. Add the assertion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 48f7c81

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit e949d4a

@H-Chris233

Copy link
Copy Markdown
Collaborator

开始审查

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit c26dfa7

@appergb appergb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

独立审核发现一个需要先修复的正确性边界:src-tauri/src/asr/elevenlabs.rs 没有设置 timestamps_granularity=none。ElevenLabs 默认返回逐词时间戳/words,而客户端只消费顶层 text,同时把完整 JSON 限制为 1 MiB;长录音可能转写成功后仍被客户端以 response too large 拒绝。请关闭未使用的逐词时间戳并补响应上限回归测试。其余主流程、安全边界及 CI 审核通过。

@appergb

appergb commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Superseded by #807, which includes this ElevenLabs Scribe v2 integration plus the response-size and cancellation fixes from independent review. #807 passed all five CI checks and was merged into beta as 145a0ea.

@appergb appergb closed this Jul 14, 2026
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] 新增 ElevenLabs Scribe 语音转录供应商

3 participants