forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtts.py
More file actions
31 lines (23 loc) · 1.12 KB
/
Copy pathtts.py
File metadata and controls
31 lines (23 loc) · 1.12 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
"""Pydantic models for the TTS (text-to-speech) proxy endpoint.
Defines the request shape shared by mobile and desktop clients.
"""
from typing import Optional
from pydantic import BaseModel, ConfigDict, Field
DEFAULT_VOICE_ID = "BAMYoBHLZM7lJgJAmFz0" # Sloane
DEFAULT_MODEL_ID = "eleven_turbo_v2_5"
DEFAULT_OUTPUT_FORMAT = "mp3_44100_128"
class TtsVoiceSettings(BaseModel):
stability: Optional[float] = None
similarity_boost: Optional[float] = None
style: Optional[float] = None
use_speaker_boost: Optional[bool] = None
class TtsSynthesizeRequest(BaseModel):
# `model_id` collides with pydantic's `model_` protected namespace; disable.
model_config = ConfigDict(protected_namespaces=())
# Upper bound mirrors _TTS_REQUEST_CHAR_LIMIT in routers/tts.py (and the Rust backend), so an
# oversized request is rejected at the schema/contract boundary rather than only at runtime.
text: str = Field(..., min_length=1, max_length=5000)
voice_id: str = DEFAULT_VOICE_ID
model_id: str = DEFAULT_MODEL_ID
output_format: str = DEFAULT_OUTPUT_FORMAT
voice_settings: Optional[TtsVoiceSettings] = None