53fb25efcf
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 2s
CI/CD Pipeline / Check push changed paths (push) Successful in 19s
CI/CD Pipeline / Build Staging API Image (push) Successful in 41s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 48s
CI/CD Pipeline / Integration Tests (push) Successful in 3m10s
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 3m17s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 3m30s
CI/CD Pipeline / Validate - Style (push) Successful in 4m17s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 59s
CI/CD Pipeline / Frontend Unit Tests (push) Failing after 5m33s
CI/CD Pipeline / Validate - Security (push) Successful in 7m12s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 2m38s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m13s
CI/CD Pipeline / Unit Tests (push) Successful in 10m11s
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Staging E2E Tests (push) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (push) Failing after 26h14m3s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 26h24m21s
CI/CD Pipeline / Retag skipped Staging API Image (push) Failing after 26h19m47s
CI/CD Pipeline / PR Build Web Image (push) Failing after 26h23m44s
CI/CD Pipeline / PR Build API Image (push) Failing after 26h23m44s
CI/CD Pipeline / Deploy Production (push) Failing after 26h13m23s
CI/CD Pipeline / Build Production Web Image (push) Failing after 26h13m26s
CI/CD Pipeline / CI Gate (push) Failing after 26h13m25s
CI/CD Pipeline / Build Production API Image (push) Failing after 26h13m26s
CI/CD Pipeline / Canary Release to Production (push) Failing after 26h13m23s
CI/CD Pipeline / Retag skipped Staging Web Image (push) Failing after 26h19m46s
CI/CD Pipeline / Frontend Lint (push) Failing after 26h23m37s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 26h23m45s
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Failing after 26h19m46s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
126 lines
3.7 KiB
Python
126 lines
3.7 KiB
Python
"""TTS 合成 API Schema。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from datetime import datetime
|
||
from typing import Any, Optional
|
||
|
||
from pydantic import BaseModel, Field
|
||
|
||
|
||
class TTSSynthesizeRequest(BaseModel):
|
||
"""TTS 合成请求。"""
|
||
|
||
text: str = Field(..., min_length=1, max_length=10000, description="合成文本")
|
||
voice_id: str = Field("", description="音色 ID")
|
||
output_name: str = Field("", description="输出文件名")
|
||
language: str = Field("zh-CN", description="语言")
|
||
speed: float = Field(1.0, ge=0.5, le=2.0, description="语速")
|
||
emotion: str = Field(
|
||
"",
|
||
description="情绪(中文/英文:自然/兴奋/沉稳/亲切/开心/悲伤/愤怒/惊讶/恐惧/厌恶 等;通过 instruction 自然语言指令控制)",
|
||
)
|
||
voice_model: str = Field("", description="语音模型名称")
|
||
voice_clone_profile_id: str = Field("", description="关联的音色克隆档案 ID")
|
||
format: str = Field("mp3", description="输出格式(mp3/wav/pcm)")
|
||
metadata_: Optional[dict[str, Any]] = Field(default=None, alias="metadata", description="额外元数据")
|
||
|
||
class Config:
|
||
populate_by_name = True
|
||
|
||
|
||
class TTSJobResponse(BaseModel):
|
||
"""TTS 任务响应。"""
|
||
|
||
id: str
|
||
user_id: str
|
||
input_text: str
|
||
voice_id: str = ""
|
||
voice_model: str = ""
|
||
project_id: str = ""
|
||
voice_clone_profile_id: str = ""
|
||
status: str
|
||
output_audio_url: str = ""
|
||
output_audio_key: str = ""
|
||
duration: float = 0.0
|
||
file_size: int = 0
|
||
sample_rate: int = 22050
|
||
format: str = "mp3"
|
||
error_message: str = ""
|
||
retry_count: int = 0
|
||
max_retries: int = 3
|
||
metadata_: Optional[dict[str, Any]] = Field(default=None, alias="metadata", description="额外元数据")
|
||
started_at: Optional[datetime] = None
|
||
completed_at: Optional[datetime] = None
|
||
created_at: datetime
|
||
updated_at: datetime
|
||
|
||
class Config:
|
||
populate_by_name = True
|
||
|
||
|
||
class TTSStatusResponse(BaseModel):
|
||
"""TTS 任务状态响应(用于轮询)。"""
|
||
|
||
id: str
|
||
status: str
|
||
output_audio_url: str = ""
|
||
error_message: str = ""
|
||
duration: float = 0.0
|
||
retry_count: int = 0
|
||
created_at: datetime
|
||
updated_at: datetime
|
||
|
||
|
||
class TTSSynthesizeResponse(BaseModel):
|
||
"""TTS 合成创建响应。"""
|
||
|
||
job_id: str
|
||
status: str
|
||
message: str = "合成任务已创建"
|
||
|
||
|
||
class ListTTSJobResponse(BaseModel):
|
||
"""TTS 任务列表响应。"""
|
||
|
||
items: list[TTSJobResponse]
|
||
total: int
|
||
page: int
|
||
page_size: int
|
||
|
||
|
||
class SaveToLibraryRequest(BaseModel):
|
||
"""保存到配音库请求。"""
|
||
|
||
name: Optional[str] = Field(None, description="配音素材名称,留空则自动生成")
|
||
|
||
|
||
class SaveToLibraryResponse(BaseModel):
|
||
"""保存到配音库响应。"""
|
||
|
||
id: str
|
||
name: str
|
||
audio_url: str
|
||
duration: float
|
||
voice_id: str
|
||
voice_name: str
|
||
status: str
|
||
|
||
|
||
class TTSPreviewRequest(BaseModel):
|
||
"""TTS 预览(试听)请求。"""
|
||
|
||
text: str = Field(..., min_length=1, max_length=200, description="合成文本,限制 200 字")
|
||
voice_id: str = Field(..., min_length=1, description="音色 ID")
|
||
speed: float = Field(1.0, ge=0.5, le=2.0, description="语速")
|
||
emotion: str = Field("", description="情绪(中文/英文:自然/兴奋/沉稳/亲切/开心/悲伤/愤怒/惊讶/恐惧/厌恶 等)")
|
||
language: str = Field("zh-CN", description="语言(zh-CN/en-US 等)")
|
||
pitch: float = Field(1.0, ge=0.5, le=2.0, description="音调(预留,当前未使用)")
|
||
|
||
|
||
class TTSPreviewResponse(BaseModel):
|
||
"""TTS 预览(试听)响应。"""
|
||
|
||
audio_url: str = Field(..., description="合成音频 URL")
|
||
duration: Optional[float] = Field(default=None, description="音频时长(秒)")
|