| 1 | # Copyright (C) 2025 AIDC-AI |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | # See the License for the specific language governing permissions and |
| 11 | # limitations under the License. |
| 12 | |
| 13 | """ |
| 14 | TTS API schemas |
| 15 | """ |
| 16 | |
| 17 | from typing import Optional |
| 18 | from pydantic import BaseModel, Field |
| 19 | |
| 20 | |
| 21 | class TTSSynthesizeRequest(BaseModel): |
| 22 | """TTS synthesis request""" |
| 23 | text: str = Field(..., description="Text to synthesize") |
| 24 | workflow: Optional[str] = Field( |
| 25 | None, |
| 26 | description="TTS workflow key (e.g., 'runninghub/tts_edge.json' or 'selfhost/tts_edge.json'). If not specified, uses default workflow from config." |
| 27 | ) |
| 28 | ref_audio: Optional[str] = Field( |
| 29 | None, |
| 30 | description="Reference audio path for voice cloning (optional). Can be a local file path or URL." |
| 31 | ) |
| 32 | voice_id: Optional[str] = Field( |
| 33 | None, |
| 34 | description="Voice ID (deprecated, use workflow instead)" |
| 35 | ) |
| 36 | |
| 37 | class Config: |
| 38 | json_schema_extra = { |
| 39 | "example": { |
| 40 | "text": "Hello, welcome to Pixelle-Video!", |
| 41 | "workflow": "runninghub/tts_edge.json", |
| 42 | "ref_audio": None |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | |
| 47 | class TTSSynthesizeResponse(BaseModel): |
| 48 | """TTS synthesis response""" |
| 49 | success: bool = True |
| 50 | message: str = "Success" |
| 51 | audio_path: str = Field(..., description="Path to generated audio file") |
| 52 | duration: float = Field(..., description="Audio duration in seconds") |
| 53 | |
| 54 |