File size: 1,753 Bytes
1c49e44 32989ce 1c49e44 32989ce 1c49e44 32989ce 1c49e44 32989ce d8bf43a f259f51 d8bf43a f259f51 d8bf43a f259f51 6d3f287 f259f51 d8bf43a f259f51 d8bf43a 32989ce 1c49e44 32989ce 1c49e44 32989ce |
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 |
from pydantic import BaseModel, Field, validator
from typing import List, Optional
import uuid
class Speak(BaseModel):
paragraphId: str = Field(default_factory=lambda: str(uuid.uuid4()))
speaker: str
text: str
voiceId: str = Field(
default="c60166365edf46589657770d", alias="speaker"
) # Default speaker value
def __init__(self, **data):
data["text"] = (
data.get("text")
if "<speak>" in data.get("text")
else f"<speak>{data.get('text')}</speak>"
)
super().__init__(**data)
class DescriptSfxRequest(BaseModel):
query: str
class DescriptTranscript(BaseModel):
audio_url: List[str]
text: str
file_extenstion: str = ".wav"
class DescriptRequest(BaseModel):
text: str
speaker: Optional[str] = Field(default="Lawrance")
_voice_id: Optional[str]
class DescriptStatusRequest(BaseModel):
id: str
class HeyGenTTSRequest(BaseModel):
voice_id: str = Field(default="d7bbcdd6964c47bdaae26decade4a933")
rate: str = Field(default="1")
pitch: str = Field(default="-3%")
text: str = "Sample"
@validator("text")
def validate_age(cls, value, values):
if not "speak" in value:
return f'<speak> <voice name="{values.get("voice_id")}"><prosody rate="{values.get("rate")}" pitch="{values.get("pitch")}">{value}</prosody></voice></speak>'
else:
return value
class TTSGenerateRequest(BaseModel):
paragraphs: List[Speak]
requestId: str = Field(default_factory=lambda: str(uuid.uuid4()))
workspaceId: str = Field(default_factory=lambda: str(uuid.uuid4()))
class StatusRequest(BaseModel):
requestId: str
class GetTranscriptions(BaseModel):
userId: int
|