Files
xiaoxia-saas/apps/api/app/schemas/voice_clone.py
T
xiaoxia c861e90289
CI/CD Pipeline / Canary Release to Production (push) Has been skipped
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Validate - Code Quality (push) Successful in 6m40s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 3m23s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 3m45s
CI/CD Pipeline / Unit Tests (push) Successful in 10m32s
CI/CD Pipeline / Integration Tests (push) Successful in 2m21s
CI/CD Pipeline / Frontend Lint (push) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 2m22s
CI/CD Pipeline / PR Build API Image (push) Has been skipped
CI/CD Pipeline / PR Build Web Image (push) Has been skipped
CI/CD Pipeline / PR Build Worker Image (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Successful in 12m24s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 2m27s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 5m3s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m10s
CI/CD Pipeline / Staging E2E Tests (push) Successful in 2m51s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 5m16s
CI/CD Pipeline / Build Production API Image (push) Has been skipped
CI/CD Pipeline / Build Production Web Image (push) Has been skipped
CI/CD Pipeline / Build Production Worker Image (push) Has been skipped
CI/CD Pipeline / Deploy Production (push) Has been skipped
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 41s
CI/CD Pipeline / CI Gate (push) Has been skipped
feat(#1195): 新增克隆音色试听接口 /voice-clones/{id}/preview (#1201)
2026-07-30 16:47:50 +08:00

88 lines
2.2 KiB
Python
Executable File

"""音色克隆 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
class VoiceClonePreviewResponse(BaseModel):
"""克隆音色试听响应。"""
clone_id: str
"""音色克隆档案 ID"""
voice_id: str
"""CosyVoice 音色 ID"""
audio_url: str
"""试听音频 URL"""
text: str
"""试听文本"""
duration: float = 0.0
"""音频时长(秒)"""
file_size: int = 0
"""文件大小(字节)"""