a9f596fca3
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 3s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 3s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Style (pull_request) Has been skipped
CI/CD Pipeline / Validate - Security (pull_request) Has been skipped
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 1m2s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m5s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m19s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 5m58s
AI Code Review / AI Code Review (pull_request) Successful in 6m48s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 8m10s
CI/CD Pipeline / CI Gate (pull_request) Successful in 1s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 0s
CI/CD Pipeline / Check if frontend-only change (push) Has been skipped
CI/CD Pipeline / Check push changed paths (push) Successful in 2s
CI/CD Pipeline / Frontend Lint (push) Has been skipped
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 Web Image (push) Successful in 2m33s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 3m43s
CI/CD Pipeline / Build Staging API Image (push) Successful in 7m32s
CI/CD Pipeline / Validate - Style (push) Successful in 36m8s
CI/CD Pipeline / Unit Tests (push) Successful in 41m59s
CI/CD Pipeline / Integration Tests (push) Successful in 42m40s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 46m4s
CI/CD Pipeline / Retag skipped Staging API Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (push) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Has been skipped
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 49m6s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 7m56s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m36s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 4m47s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 20m52s
CI/CD Pipeline / Validate - Security (push) Successful in 2h17m39s
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 / CI Gate (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 / Canary Release to Production (push) Has been skipped
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
137 lines
4.3 KiB
Python
137 lines
4.3 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="语速")
|
||
style: Optional[str] = Field(
|
||
None,
|
||
description="语气风格(natural/sweet/excited/professional/news/livestream),可选;优先级高于 emotion",
|
||
)
|
||
volume: Optional[int] = Field(None, ge=0, le=100, description="音量(0-100),默认 50")
|
||
pitch: Optional[float] = Field(None, ge=0.5, le=2.0, description="音调(0.5-2.0),默认 1.0")
|
||
emotion: str = Field(
|
||
"",
|
||
description="[deprecated] 旧情绪参数,内部映射为 style;新接入请使用 style",
|
||
)
|
||
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="语速")
|
||
style: Optional[str] = Field(
|
||
None,
|
||
description="语气风格(natural/sweet/excited/professional/news/livestream),可选;优先级高于 emotion",
|
||
)
|
||
volume: Optional[int] = Field(None, ge=0, le=100, description="音量(0-100),默认 50")
|
||
emotion: str = Field("", description="[deprecated] 旧情绪参数,内部映射为 style")
|
||
language: str = Field("zh-CN", description="语言(zh-CN/en-US 等)")
|
||
pitch: float = Field(1.0, ge=0.5, le=2.0, description="音调(0.5-2.0),默认 1.0")
|
||
|
||
|
||
class TTSPreviewResponse(BaseModel):
|
||
"""TTS 预览(试听)响应。"""
|
||
|
||
audio_url: str = Field(..., description="合成音频 URL")
|
||
duration: Optional[float] = Field(default=None, description="音频时长(秒)")
|