Files
AI-Video/api/schemas/tts.py
2025-11-07 16:59:12 +08:00

42 lines
1.2 KiB
Python

"""
TTS API schemas
"""
from typing import Optional
from pydantic import BaseModel, Field
class TTSSynthesizeRequest(BaseModel):
"""TTS synthesis request"""
text: str = Field(..., description="Text to synthesize")
workflow: Optional[str] = Field(
None,
description="TTS workflow key (e.g., 'runninghub/tts_edge.json' or 'selfhost/tts_edge.json'). If not specified, uses default workflow from config."
)
ref_audio: Optional[str] = Field(
None,
description="Reference audio path for voice cloning (optional). Can be a local file path or URL."
)
voice_id: Optional[str] = Field(
None,
description="Voice ID (deprecated, use workflow instead)"
)
class Config:
json_schema_extra = {
"example": {
"text": "Hello, welcome to Pixelle-Video!",
"workflow": "runninghub/tts_edge.json",
"ref_audio": None
}
}
class TTSSynthesizeResponse(BaseModel):
"""TTS synthesis response"""
success: bool = True
message: str = "Success"
audio_path: str = Field(..., description="Path to generated audio file")
duration: float = Field(..., description="Audio duration in seconds")