Athos Developer Docs
Frontend SDK

Microphone & audio

Device selection, mute, autoplay recovery, and reconnect behavior.

The SDK manages the microphone and the audio element for you. It auto-creates the <audio> element that plays the persona's voice and appends it to the page — you don't manage playback yourself.

Selecting a microphone

const mics = await session.listMicrophones(); // [{ deviceId, label }]
await session.setMicrophone(mics[0].deviceId); // switch mid-call, no drop

listMicrophones() may prompt the user for microphone permission the first time. setMicrophone() switches the active input without dropping the call — wire it to a settings dropdown.

Mute

await session.mute();
await session.unmute();

Autoplay recovery

Browsers block audio autoplay until the user interacts with the page. If playback is blocked, the SDK emits an error with code AUDIO_PLAYBACK_BLOCKED. Recover by calling resumeAudio() from within a user-gesture handler (a click) — browsers only unblock audio then.

session.on('error', ({ code }) => {
  if (code === 'AUDIO_PLAYBACK_BLOCKED') showResumeButton();
});

// in your button's click handler:
resumeButton.onclick = () => session.resumeAudio();

Reconnect behavior

On a transient network drop the SDK reconnects automatically:

  drop ──▶ reconnecting ──▶ reconnected        (recovered)
                       └──▶ error: NETWORK_LOST (after 30s, session ends)
  • It emits reconnecting, then reconnected on recovery.
  • If recovery does not succeed within 30 seconds, it emits an error with code NETWORK_LOST and ends the session.

Show a non-blocking banner on reconnecting and clear it on reconnected; treat NETWORK_LOST as a terminal error and offer to restart.

Microphone errors

CodeMeaning
MIC_PERMISSION_DENIEDThe user denied microphone permission. Prompt them to allow it.
MIC_DEVICE_DISCONNECTEDThe active mic was unplugged mid-call. Offer listMicrophones() again.
NO_MIC_AVAILABLENo microphone is available on this device.

See the full list in Error codes.

On this page