Hear the person
Eachaudio event carries interleaved signed 16-bit samples. The default is 48 kHz stereo; ask for the format your speech-to-text wants when you build the transport.
InputAudioRawFrames at the pipeline’s audio_in_sample_rate. LiveKit Agents receives 24 kHz mono, the format of a LiveKit room.
Speak to the person
Write PCM16 at any sample rate.writeAudio returns once the audio is queued; waitForPlayout returns when the queue is empty and the last packet has left.
Stop talking when interrupted
When the person starts speaking over your agent, drop what has not left yet.clearAudio empties the queue, and a pending waitForPlayout returns at once.
Mute your agent
setMuted(true) publishes your agent’s mute state to the room as a userUpdate frame, and every participant’s roomState then reports it. Stop writing audio as well.

