Pcm16AudioCodec

Vendor-neutral encoding for PCM16 audio frames carried as base64 payloads.

Lives in core (rather than per-provider gateways) because the broker needs to decode audio deltas when normalising realtime events, and the encoding itself is provider-agnostic — every realtime API currently in scope (OpenAI, prospective Anthropic, Google) frames PCM16 as little-endian 16-bit samples behind base64.

Functions

Link copied to clipboard
fun decode(base64: String, sampleRateHz: Int = AudioFrame.DEFAULT_SAMPLE_RATE_HZ): AudioFrame

Decode a base64 string of little-endian PCM16 bytes back into an AudioFrame.

Link copied to clipboard
fun encode(frame: AudioFrame): String

Encode a PCM16 AudioFrame into a base64 string.