feat: 集成豆包 ASR 语音识别后端,支持 /voice doubao 切换#357
Conversation
- 新增 src/services/doubaoSTT.ts 适配模块,将 doubaoime-asr 的 AsyncGenerator 协议适配为现有 VoiceStreamConnection 接口 - /voice doubao 启用豆包后端,/voice 使用默认 Anthropic 后端 - 后端选择持久化到 settings.json 的 voiceProvider 字段 - 豆包后端跳过 Anthropic OAuth 认证、语言限制和 Focus Mode - 豆包后端松手即出结果,跳过 processing 状态 - 凭证文件存放在 ~/.claude/tts/doubao/credentials.json - doubaoime-asr 作为 optionalDependencies 安装 - 移除 /voice 命令的 claude-ai 可用性限制,所有用户可用 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds Doubao ASR as an optional voice provider alongside Anthropic: new Doubao streaming adapter, settings schema for provider selection, command/hook changes to route between providers, optional dependency and gitignore update, and documentation updates reflecting dual-backend voice mode. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Cmd as Voice Command
participant Settings as Settings Store
participant Hook as useVoice Hook
participant Provider as Provider Adapter<br/>(Doubao / Anthropic)
participant ASR as ASR Backend
User->>Cmd: /voice doubao (or anthropic)
Cmd->>Settings: isVoiceAvailable()
alt available
Cmd->>Settings: determine provider from args
alt provider == Anthropic
Cmd->>Provider: run Anthropic auth check
else provider == Doubao
Note right of Cmd: Skip Anthropic OAuth check
end
Cmd->>Settings: set voiceProvider, enable voice
User->>Hook: start recording
Hook->>Settings: read voiceProvider
alt provider == Doubao
Hook->>Provider: connectDoubaoStream(language?)
Provider->>ASR: open stream (credentials file)
else provider == Anthropic
Hook->>Provider: connectVoiceStream(keyterms)
Provider->>ASR: open stream (OAuth)
end
ASR->>Provider: stream audio chunks
Provider->>Hook: INTERIM_RESULT / FINAL_RESULT
Hook->>User: display transcripts
else unavailable
Cmd->>User: return unavailable message
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Summary by CodeRabbit
New Features
Documentation
Chores
Tests