File size: 853 Bytes
35bb6f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

from typing import Literal

from pydantic import BaseModel, Field


class WSMessage(BaseModel):
    type: Literal["start", "text", "stop", "ping"]


class WSStartMessage(WSMessage):
    type: Literal["start"] = "start"
    model: str = "neutts-nano-q4-gguf"
    voice: str = "jo"
    response_format: Literal["mp3", "opus", "aac", "flac", "wav", "pcm"] = "pcm"
    sample_rate: int = 24000


class WSTextMessage(WSMessage):
    type: Literal["text"] = "text"
    text: str = Field(..., min_length=1)


class WSStopMessage(WSMessage):
    type: Literal["stop"] = "stop"


class WSPingMessage(WSMessage):
    type: Literal["ping"] = "ping"


class WSResponseMessage(BaseModel):
    type: Literal["audio", "error", "done", "pong"]
    data: str | None = None
    message: str | None = None
    format: str | None = None