agent.mjs
Bridging a realtime model
To connect a realtime speech-to-speech model instead, keep the same loop:- Join at the model’s native rate (for example 24 kHz) so no resampling is needed.
- Forward each binary frame from X to the model’s audio input.
- Forward each audio chunk the model produces to X as a binary frame.
- When the model reports that the user started speaking (or X sends
speech.started), sendaudio.clear. - On
session.ended, close the model session.