Files
sionrui/openspec/changes/refactor-voice-provider/tasks.md
2026-01-27 01:39:08 +08:00

54 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Implementation Tasks
## 1. 接口与基础结构
- [ ] 1.1 创建 `VoiceCloneProvider` 接口
- 定义 `cloneVoice(VoiceCloneRequest)` 方法
- 定义 `synthesize(VoiceTtsRequest)` 方法
- 定义 `supports(String providerType)` 方法
- [ ] 1.2 创建统一 DTO 类
- `VoiceCloneRequest` - 语音克隆请求
- `VoiceCloneResult` - 语音克隆响应
- `VoiceTtsRequest` - 语音合成请求
- `VoiceTtsResult` - 语音合成响应
- [ ] 1.3 创建 `VoiceCloneProviderFactory` 工厂类
- 根据配置获取 Provider 实例
- 支持动态切换供应商
## 2. CosyVoice 重构(保持现有功能)
- [ ] 2.1 重命名 `CosyVoiceClient``CosyVoiceProvider`
- [ ] 2.2 `CosyVoiceProvider` 实现 `VoiceCloneProvider` 接口
- [ ] 2.3 适配现有 DTO 到新的统一 DTO
- [ ] 2.4 保持现有 DashScope SDK 调用逻辑不变
## 3. 配置重构
- [ ] 3.1 创建 `VoiceProviderProperties` 配置类
- 支持多供应商配置结构
- 添加 `default-provider` 配置项
- [ ] 3.2 创建 `CosyVoiceProviderConfig` (嵌套配置)
- [ ] 3.3 保持向后兼容:支持读取旧的 `yudao.cosyvoice.*` 配置
## 4. Service 层改造
- [ ] 4.1 修改 `TikUserVoiceServiceImpl`
- 注入 `VoiceCloneProvider` 而非 `CosyVoiceClient`
- 使用工厂获取 Provider 实例
- [ ] 4.2 更新方法调用
- `createVoice()` - 使用 `provider.cloneVoice()`
- `synthesizeVoice()` - 使用 `provider.synthesize()`
- `previewVoice()` - 使用 `provider.synthesize()`
## 5. 测试与验证
- [ ] 5.1 单元测试CosyVoiceProvider
- [ ] 5.2 单元测试VoiceCloneProviderFactory
- [ ] 5.3 集成测试TikUserVoiceServiceImpl
- [ ] 5.4 验证现有功能正常运行
## 6. 文档与配置迁移
- [ ] 6.1 更新 `application.yaml` 配置示例
- [ ] 6.2 添加配置迁移说明文档
---
**总计**: 20 项任务
**预计工作量**: 2-3 天