Files
xiaoxia-saas/apps/api/app/schemas/voice_clone.py
T
灵应 c55dafdbb1
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 170h0m19s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 170h0m23s
Deploy / Deploy Staging (push) Failing after 170h2m52s
CI/CD Pipeline / Frontend Lint (push) Failing after 170h3m23s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 170h3m30s
feat: implement voice clone API (Task 3.05)
- Add VoiceCloneProfile CRUD endpoints:
  POST /api/v1/voice-clones (create clone task, status=pending)
  GET /api/v1/voice-clones (list with pagination + status filter)
  GET /api/v1/voice-clones/{id} (get details)
  GET /api/v1/voice-clones/{id}/status (polling endpoint)
  DELETE /api/v1/voice-clones/{id} (soft delete)
  POST /api/v1/voice-clones/{id}/retry (retry failed clone)
- Add VoiceCloneProfile SQLAlchemy model and repository adapter
- Add Alembic migration 019 for voice_clone_profiles table
- Add use cases: Create, List, Get, GetStatus, Delete, Retry
- Add Pydantic schemas for request/response validation
- Add 19 unit tests (all passing)
- CosyVoice API integration deferred to Task 3.07

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 10:50:57 +08:00

70 lines
1.8 KiB
Python

"""音色克隆 API Schema。"""
from __future__ import annotations
from datetime import datetime
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
class CreateVoiceCloneRequest(BaseModel):
"""创建音色克隆请求。"""
name: str = Field(..., min_length=1, max_length=100, description="音色名称")
description: str = Field("", description="音色描述")
source_audio_url: str = Field("", description="参考音频 URL")
voice_model: str = Field("", description="语音模型名称")
language: str = Field("zh-CN", description="语言")
gender: str = Field("unknown", description="性别")
max_retries: int = Field(3, ge=1, le=10, description="最大重试次数")
metadata_: Optional[Dict[str, Any]] = Field(
default=None, alias="metadata", description="额外元数据"
)
class Config:
populate_by_name = True
class VoiceCloneProfileResponse(BaseModel):
"""音色克隆档案响应。"""
id: str
user_id: str
name: str
description: str = ""
source_audio_url: str = ""
voice_id: str = ""
voice_model: str = ""
language: str = "zh-CN"
gender: str = "unknown"
status: str
error_message: str = ""
retry_count: int = 0
max_retries: int = 3
metadata_: Optional[Dict[str, Any]] = Field(
default=None, alias="metadata", description="额外元数据"
)
created_at: datetime
updated_at: datetime
class Config:
populate_by_name = True
class VoiceCloneStatusResponse(BaseModel):
"""音色克隆状态响应(用于轮询)。"""
id: str
status: str
error_message: str = ""
voice_id: str = ""
retry_count: int = 0
class ListVoiceCloneResponse(BaseModel):
"""音色克隆列表响应。"""
items: List[VoiceCloneProfileResponse]
total: int