Spaces:
Runtime error
Runtime error
File size: 1,002 Bytes
f32a529 |
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
from pydantic import BaseModel, validator
from src.model.language import Language
SUPPORTED_GENDERS = {'male', 'female'}
class Sentence(BaseModel):
source: str
@validator('source', pre=True)
def blank_string_in_source(cls, value, field):
if value == "":
raise ValueError('source cannot be empty')
return value
class TTSConfig(BaseModel):
language: Language
gender: str
@validator('gender', pre=True)
def blank_string_in_gender(cls, value, field):
if value == "":
raise ValueError('gender cannot be empty')
if value not in SUPPORTED_GENDERS:
raise ValueError('Unsupported gender value')
return value
class TTSRequest(BaseModel):
input: List[Sentence]
config: TTSConfig
@validator('input', pre=True)
def input_cannot_be_empty(cls, value, field):
if len(value) < 1:
raise ValueError('input cannot be empty')
return value
|