Frames

March 10, 2026 · View on GitHub

Package frames defines frame types for the Voxray pipeline: audio, text, system, control, and vendor-specific (RTVI, DTMF). The serialize subpackage provides wire serialization (JSON, protobuf, Twilio, Telnyx, etc.).

Purpose

  • Frame: Interface implemented by all frames; FrameType(), ID(), PTS(), Metadata().
  • Base: Common id, pts, metadata; embed in concrete frames. IDs are unique (atomic counter).
  • Concrete frames: System (Start, End, Cancel, Error, Stop), control (Sync, Interruption, user/bot turn), data (Text, Transcription, AudioRaw, TTSAudioRaw, LLM*, TransportMessage, DTMF, etc.).
  • Serialization: serialize.Serializer (Serialize/Deserialize); JSON envelope, protobuf, and vendor formats (Twilio, Telnyx, Plivo, Vonage, Exotel, Genesys).

Frame type hierarchy

graph TD
    Frame["Frame interface"] --> Base["Base\nid, pts, metadata"]
    Base --> System["SystemFrame"]
    Base --> Data["DataFrame"]
    Base --> Control["ControlFrame"]
    System --> Start["StartFrame"]
    System --> End["EndFrame"]
    System --> Cancel["CancelFrame"]
    System --> Error["ErrorFrame"]
    Data --> Text["TextFrame"]
    Data --> Transcription["TranscriptionFrame"]
    Data --> AudioRaw["AudioRawFrame"]
    Data --> TTSAudio["TTSAudioRawFrame"]
    Data --> LLMCtx["LLMContextFrame\nLLMTextFrame\n..."]
    Control --> Sync["SyncFrame"]
    Control --> Interruption["InterruptionFrame"]
    Control --> UserTurn["UserStartedSpeakingFrame\nUserStoppedSpeakingFrame\nUserIdleFrame"]
    Control --> BotTurn["BotStartedSpeakingFrame\nBotStoppedSpeakingFrame"]

Serializers

graph TD
    Serializer["Serializer interface"] --> JSON["JSONSerializer"]
    Serializer --> Protobuf["ProtobufSerializer"]
    Serializer --> Twilio["twilio.Serializer"]
    Serializer --> Telnyx["telnyx.Serializer"]
    Serializer --> Plivo["plivo.Serializer"]
    Serializer --> Vonage["vonage.Serializer"]
    Serializer --> Exotel["exotel.Serializer"]
    Serializer --> Genesys["genesys.Serializer"]

Exported symbols (root package)

SymbolTypeDescription
FrameinterfaceFrameType, ID, PTS, Metadata
BasestructNewBase, NewBaseWithID, ID, SetPTS, Metadata
SystemFrame, DataFrame, ControlFramestructBase embeddings
StartFrame, NewStartFramestruct/funcPipeline init; audio rates, flags
EndFrame, NewEndFramestruct/funcNormal end
CancelFrame, NewCancelFramestruct/funcStop with reason
ErrorFrame, NewErrorFramestruct/funcError, Fatal, Processor
TextFrame, NewTextFramestruct/funcText, SkipTTS, AppendToContext
TranscriptionFrame, NewTranscriptionFramestruct/funcSTT output; UserID, Timestamp, Finalized
AudioRawFrame, NewAudioRawFramestruct/funcPCM audio; SampleRate, NumChannels
TTSAudioRawFrame, NewTTSAudioRawFramestruct/funcTTS output
LLMContext, LLMContextFrame, LLMRunFrame, LLMTextFrame, etc.struct/funcLLM context, run, messages, tools, text
UserStartedSpeakingFrame, UserStoppedSpeakingFrame, UserIdleFramestruct/funcUser turn control
BotStartedSpeakingFrame, BotStoppedSpeakingFramestruct/funcBot turn control
InputDTMFFrame, OutputDTMFUrgentFramestruct/funcDTMF I/O
RTVIClientMessageFrame, RTVIServerMessageFramestructRTVI protocol
InterruptionFrame, NewInterruptionFramestruct/funcBarge-in clear
Service switcher, transport message, etc.struct/funcSee frames.go, llm.go

Subpackage serialize

SymbolDescription
SerializerSerialize(Frame) ([]byte, error), Deserialize([]byte) (Frame, error)
SerializerWithSetupOptional Setup(StartFrame)
SerializerWithMessageTypeOptional SerializeWithType → (data, binary)
JSONSerializer, ProtobufSerializerBuilt-in
twilio, telnyx, plivo, vonage, exotel, genesysVendor Serializer + Params

Concurrency

  • Frame ID generation uses atomic.AddUint64; safe for concurrent frame creation.
  • Frames are intended to be immutable after creation (except metadata); no internal locking.

Files (root)

FileDescription
frames.goFrame, Base, system/data/control frames, audio, text, transcription, error, service switcher
llm.goLLMContext, LLM* frames, TTSSpeakFrame, FunctionCallResultFrame
user_turn.goUserStartedSpeaking, UserStoppedSpeaking, UserIdle
bot_turn.goBotStartedSpeaking, BotStoppedSpeaking
vad.goVADParamsUpdate, VADUserStarted/StoppedSpeaking, UserSpeakingFrame
dtmf.goInputDTMFFrame, OutputDTMFUrgentFrame
rtvi.goRTVIClientMessageFrame, RTVIServerMessageFrame

See also