File size: 1,178 Bytes
05b45a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from typing import List, Optional, Union

from pydantic import BaseModel, Field, field_validator


class PhonemeRequest(BaseModel):
    text: str
    language: str = "a"  # Default to American English


class PhonemeResponse(BaseModel):
    phonemes: str
    tokens: list[int]


class StitchOptions(BaseModel):
    """Options for stitching audio chunks together"""

    gap_method: str = Field(
        default="static_trim",
        description="Method to handle gaps between chunks. Currently only 'static_trim' supported.",
    )
    trim_ms: int = Field(
        default=0,
        ge=0,
        description="Milliseconds to trim from chunk boundaries when using static_trim",
    )

    @field_validator("gap_method")
    @classmethod
    def validate_gap_method(cls, v: str) -> str:
        if v != "static_trim":
            raise ValueError("Currently only 'static_trim' gap method is supported")
        return v


class GenerateFromPhonemesRequest(BaseModel):
    """Simple request for phoneme-to-speech generation"""

    phonemes: str = Field(..., description="Phoneme string to synthesize")
    voice: str = Field(..., description="Voice ID to use for generation")