dial_sdk.self_hosted_audio

Self-Hosted AUDIO protocol — the WebSocket contract your server speaks when Dial pipes the raw call audio to you, full duplex (https://docs.getdial.ai/api-reference/self-hosted-audio-protocol).

These pydantic models are the executable form of that contract, plus parse_dial_audio_message / serialize_server_audio_message. Verify the connection with verify_dial_signature (from dial_sdk.self_hosted). Configuration of Self-Hosted mode happens in the dashboard / REST API — this module is purely the protocol types for building a conformant server; you own the WebSocket loop (see the audio echo playbook).

Attributes

Classes

Functions

parse_dial_audio_message(→ DialAudioMessage)

Parse + validate a frame received from Dial. Raises ValidationError.

serialize_server_audio_message(→ str)

Validate + serialize an outbound frame to a JSON string.

Module Contents

class dial_sdk.self_hosted_audio.AudioCallConnected

Bases: pydantic.BaseModel

call_id: str
direction: Literal['inbound', 'outbound']
formats: AudioFormats
from_: str
instruction: str | None = None
language: str | None = None
model_config
reconnect: bool = False
to: str
type: Literal['call_connected']
class dial_sdk.self_hosted_audio.AudioCallEnded

Bases: pydantic.BaseModel

reason: CallEndReason
type: Literal['call_ended']
class dial_sdk.self_hosted_audio.AudioDtmf

Bases: pydantic.BaseModel

digit: str
type: Literal['dtmf']
class dial_sdk.self_hosted_audio.AudioDurationWarning

Bases: pydantic.BaseModel

seconds_remaining: int
type: Literal['duration_warning']
class dial_sdk.self_hosted_audio.AudioFormats

Bases: pydantic.BaseModel

inbound: AudioFormat
outbound: AudioFormat
class dial_sdk.self_hosted_audio.AudioMark

Bases: pydantic.BaseModel

name: str
type: Literal['mark']
class dial_sdk.self_hosted_audio.AudioMedia

Bases: pydantic.BaseModel

payload: str
seq: int | None = None
type: Literal['media']
class dial_sdk.self_hosted_audio.ServerAudioMedia

Bases: pydantic.BaseModel

payload: str
type: Literal['media'] = 'media'
class dial_sdk.self_hosted_audio.ServerClear

Bases: pydantic.BaseModel

type: Literal['clear'] = 'clear'
class dial_sdk.self_hosted_audio.ServerEndCall

Bases: pydantic.BaseModel

type: Literal['end_call'] = 'end_call'
class dial_sdk.self_hosted_audio.ServerMark

Bases: pydantic.BaseModel

name: str
type: Literal['mark'] = 'mark'
dial_sdk.self_hosted_audio.parse_dial_audio_message(raw: str | bytes | dict) DialAudioMessage

Parse + validate a frame received from Dial. Raises ValidationError.

dial_sdk.self_hosted_audio.serialize_server_audio_message(message: ServerAudioMessage) str

Validate + serialize an outbound frame to a JSON string.

dial_sdk.self_hosted_audio.AudioFormat
dial_sdk.self_hosted_audio.CallEndReason
dial_sdk.self_hosted_audio.DialAudioMessage
dial_sdk.self_hosted_audio.ServerAudioMessage