Skip to content

feat(asr): Apple Speech 本地 ASR provider (macOS) — 完成 #574#636

Merged
H-Chris233 merged 2 commits into
betafrom
feat/issue-574-apple-speech-asr-wire
Jun 11, 2026
Merged

feat(asr): Apple Speech 本地 ASR provider (macOS) — 完成 #574#636
H-Chris233 merged 2 commits into
betafrom
feat/issue-574-apple-speech-asr-wire

Conversation

@appergb

@appergb appergb commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

User description

概述

完成 macOS 上的 Apple Speech 本地 ASR provider,关闭 #574

本 PR 在草稿 PR #625 的 provider 基础之上,补完了全部后端接线,使 "Apple 语音" 成为可在设置中选择并实际工作的 ASR provider。合并后可取代草稿 #625

改动内容

Provider 基础(承接 #625,cherry-pick)

  • Apple Speech provider 实现 + 前端 UI/i18n(前端已用 IS_MAC 门控)

后端接线(本 PR 新增,+166 / -0,8 文件)

  • coordinator.rs:新增 ActiveAsr::AppleSpeech 变体(macOS only)
  • asr_setup.rs:build_apple_speech() 构建器、ensure_asr_credentials 平台门控(非 macOS 报错)、QA 路径接线、is_keyless_local_asr_provider
  • dictation_session.rs + dictation_end.rs:听写 start + 批处理 transcribe(沿用 local_qwen 的动态超时与 cancel/error 收尾)
  • qa_session.rs:QA transcribe 分支
  • resources.rs:cancel 分支
  • commands/providers.rs + credentials.rs:active_apple_speech_asr_is_supported(非 macOS 返回 false)、keyless 校验白名单、set_active_asr_provider 非 macOS 拒绝门控

所有 macOS 专属代码均以 #[cfg(target_os = "macos")] 门控,与现有 qwen / foundry / sherpa provider 完全同形;三平台 match 保持穷尽。

测试情况

  • cargo check(macOS aarch64):通过,无新增警告
  • provider 单元测试:5/5 通过;原有 keyless 校验测试全过
  • npm run build(tsc + vite):通过
  • macOS 真机实测(待维护者):切到 "Apple 语音" → 首次录音确认弹出系统语音识别授权框 → 出字;再测 QA 面板路径
  • Windows / Linux 编译:本地缺交叉编译 sysroot,需 CI 三平台门禁确认未破坏
  • 合并前 cargo fmt + cargo clippy 收尾

备注

Closes #574


PR Type

Enhancement, Documentation


Description

  • Add Apple Speech local ASR provider using SFSpeechRecognizer (macOS)

  • Wire provider into coordinator, dictation, and QA sessions

  • Frontend UI card for activation with i18n support

  • Platform-gate with macOS-only compilation and error messages


Diagram Walkthrough

flowchart LR
  AppleSpeechProvider["Apple Speech Provider"] --> SFSpeechRecognizer["SFSpeechRecognizer"]
  AppleSpeechProvider --> LocalAsrUI["LocalAsr UI Card"]
  LocalAsrUI --> i18n["i18n (5 languages)"]
Loading

File Walkthrough

Relevant files
Configuration changes
2 files
build.rs
Link Speech.framework for macOS                                                   
+4/-0     
Info.plist
Add NSSpeechRecognitionUsageDescription                                   
+2/-0     
Enhancement
14 files
apple_speech_provider.rs
New Apple Speech ASR provider with objc2 bridge                   
+433/-0 
mod.rs
Register Apple Speech provider and constants                         
+16/-0   
credentials.rs
Platform gate for Apple Speech provider                                   
+6/-0     
providers.rs
Add active_apple_speech_asr_is_supported                                 
+13/-0   
coordinator.rs
Add AppleSpeech variant to ActiveAsr enum                               
+4/-0     
asr_setup.rs
Build Apple Speech provider and ensure credentials             
+32/-0   
dictation_end.rs
Handle Apple Speech in dictation end session                         
+59/-0   
dictation_session.rs
Handle Apple Speech in dictation begin session                     
+16/-0   
qa_session.rs
Handle Apple Speech in QA session                                               
+34/-0   
resources.rs
Cancel Apple Speech ASR                                                                   
+2/-0     
LocalAsr.tsx
Add Apple Speech activation UI card                                           
+78/-0   
Overview.tsx
Map apple-speech ID to display name                                           
+1/-0     
ProvidersSection.tsx
Add apple-speech preset and hide from dropdown                     
+11/-5   
shared.tsx
Extend AsrPresetId type with apple-speech                               
+1/-0     
Documentation
5 files
en.ts
Add English i18n strings for Apple Speech                               
+4/-0     
ja.ts
Add Japanese i18n strings for Apple Speech                             
+4/-0     
ko.ts
Add Korean i18n strings for Apple Speech                                 
+4/-0     
zh-CN.ts
Add Simplified Chinese i18n strings for Apple Speech         
+4/-0     
zh-TW.ts
Add Traditional Chinese i18n strings for Apple Speech       
+4/-0     

吕柏青 and others added 2 commits June 10, 2026 14:49
从旧 WIP 分支抢救 provider 并重新落到当前 beta 结构;只含可干净合并的基础,coordinator/dictation 接线、命令、完整编译验证待后续(见 PR 待办)。

- asr/local/apple_speech_provider.rs:SFSpeechRecognizer 批处理识别 + 授权 + objc2 桥接 + 单测
- asr/local/mod.rs:注册 + APPLE_SPEECH_PROVIDER_ID + is_apple_speech
- build.rs:链接 Speech.framework(macOS);Info.plist:NSSpeechRecognitionUsageDescription
- 前端:LocalAsr / ProvidersSection / Overview / shared + 5 语言 i18n
…574)

承接草稿 PR #625 的 provider 基础,补完后端接线:
- coordinator: ActiveAsr::AppleSpeech 变体(macOS only)
- asr_setup: build_apple_speech + ensure_asr_credentials 平台门控 +
  build_qa_asr_start QA 接线 + is_keyless_local_asr_provider
- dictation_session/dictation_end: 听写 start + 批处理 transcribe(沿用
  local_qwen 动态超时)
- qa_session: QA transcribe arm
- resources: cancel arm
- commands: active_apple_speech_asr_is_supported(非 macOS 返回 false)+
  keyless 校验白名单 + asr_configured_for_provider + set_active_asr_provider
  非 macOS 拒绝门控

provider 仅 macOS 编译;非 macOS 由门控判不可用。前端 UI/i18n 已随 #625 落地。
验证:cargo check(macOS)通过、provider 单测 5/5 通过、npm run build 通过。

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

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

625 - Partially compliant

Compliant requirements:

  • Provider 实现(apple_speech_provider.rs) - 注册 provider + APPLE_SPEECH_PROVIDER_ID + is_apple_speech() - build.rs 链接 Speech.framework - Info.plist 添加 NSSpeechRecognitionUsageDescription - 前端 LocalAsr 页 / ProvidersSection / Overview / shared + i18n - dictation 接线(dictation_session.rs + dictation_end.rs) - coordinator 状态/选择接入(asr_setup.rs + coordinator.rs) - 命令模块非 macOS 门控(commands/providers.rs + credentials.rs)

Non-compliant requirements:

(empty)

Requires further human verification:

  • 编译验证(依赖 CI,人工确认 cargo check 通过)
  • fmt + clippy(开发者需在合并前运行)

574 - Partially compliant

Compliant requirements:

  • macOS 上能看到 Apple Speech ASR 选项(前端 UI 和设置页) - 后端接线完成,实际可用

Non-compliant requirements:

(empty)

Requires further human verification:

  • macOS 真机实测(首次授权弹框、录音、出字)
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
⚡ No major issues detected

@H-Chris233 H-Chris233 merged commit 834dd63 into beta Jun 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MacOS Apple Silicon 看不到 ASR 选项中有 Apple Speech

2 participants