forked from devnen/Kitten-TTS-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
72 lines (55 loc) · 2.33 KB
/
models.py
File metadata and controls
72 lines (55 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File: models.py
# Pydantic models for API request and response validation.
from typing import Optional, Literal
from pydantic import BaseModel, Field
class GenerationParams(BaseModel):
"""Common parameters for TTS generation."""
speed: Optional[float] = Field(
None,
ge=0.25,
le=4.0,
description="Speed factor for the generated audio. 1.0 is normal speed.",
)
language: Optional[str] = Field(
None,
description="Language of the text. (Primarily for UI, actual engine may infer)",
)
class CustomTTSRequest(BaseModel):
"""Request model for the custom /tts endpoint."""
text: str = Field(..., min_length=1, description="Text to be synthesized.")
voice: str = Field(
...,
description="Voice identifier (e.g., 'expr-voice-5-m'). Available voices: expr-voice-2-m, expr-voice-2-f, expr-voice-3-m, expr-voice-3-f, expr-voice-4-m, expr-voice-4-f, expr-voice-5-m, expr-voice-5-f",
)
output_format: Optional[Literal["wav", "opus", "mp3"]] = Field(
"wav", description="Desired audio output format."
)
split_text: Optional[bool] = Field(
True,
description="Whether to automatically split long text into chunks for processing.",
)
chunk_size: Optional[int] = Field(
120,
ge=50,
le=500,
description="Approximate target character length for text chunks when splitting is enabled (50-500).",
)
# Embed generation parameters directly
speed: Optional[float] = Field(
None, description="Overrides default speed if provided."
)
language: Optional[str] = Field(
None, description="Overrides default language if provided."
)
class ErrorResponse(BaseModel):
"""Standard error response model for API errors."""
detail: str = Field(..., description="A human-readable explanation of the error.")
class UpdateStatusResponse(BaseModel):
"""Response model for status updates, e.g., after saving settings."""
message: str = Field(
..., description="A message describing the result of the operation."
)
restart_needed: Optional[bool] = Field(
False,
description="Indicates if a server restart is recommended or required for changes to take full effect.",
)