@braintrust/audio package compresses voice recordings that Braintrust instrumentation captures, such as LiveKit Agents call audio. With the package installed, recordings upload as Opus audio in Ogg files (audio/ogg) instead of raw PCM.
Installation
We strongly recommend using@braintrust/audio to compress recordings and reduce upload size. Install the package alongside braintrust v3.41.0 or later. It requires Node.js 20 or later.
Quick start
Braintrust finds and loads@braintrust/audio from node_modules automatically, so you don’t import it in your code. Once you turn on LiveKit Agents audio recording with BRAINTRUST_CAPTURE_USER_AUDIO_ATTACHMENTS or BRAINTRUST_CAPTURE_AGENT_AUDIO_ATTACHMENTS, recordings upload as Opus audio in Ogg files.
If you deploy a bundle without node_modules, import the package in your app so your bundler includes it:
braintrust version, or the audio options contain an unsupported value, recordings upload as raw PCM and Braintrust logs a warning that explains why.
Configuration
To change the encoding, passaudio options for the livekit integration to configureInstrumentation() from braintrust/instrumentation. Call it in a separate file, and load that file before the hook.
configure.mjs
See Compress recordings for how these settings apply to LiveKit Agents.