Type alias EchoCancellation

EchoCancellation: "off" | "aggressive" | "balanced" | {
    sampleRate?: 16000 | 32000 | 48000;
    suppressionMode?: "balanced" | "aggressive";
    highPassFilter?: boolean;
    residualEchoGate?: boolean;
}

Acoustic echo cancellation applied to microphone audio. Captures system/playback audio via Core Audio process taps and removes it from the microphone signal in real time using WebRTC AEC3.

  • 'off': No echo cancellation (default).
  • 'aggressive': Maximum echo removal at the cost of speech quality — aggressive suppression, high-pass filter, and residual echo gate at 16 kHz. Optimized for speech-to-text pipelines where echo removal matters more than audio fidelity.
  • 'balanced': Balanced echo removal that preserves speech quality — balanced suppression with high-pass filter but no residual echo gate at 48 kHz. Optimized for recording pipelines where audio fidelity is more important than pure echo removal.
  • An object for full control over the AEC3 configuration; omitted fields default to the 'balanced' preset.

Type declaration

  • Optional sampleRate?: 16000 | 32000 | 48000

    Sample rate the echo canceller runs at, in Hz. Defaults to 48000. 16 kHz is sufficient for speech-to-text; 48 kHz preserves full audio fidelity.

  • Optional suppressionMode?: "balanced" | "aggressive"

    Echo suppression mode. Defaults to 'balanced'.

    • 'balanced': Conservative suppression that allows AEC3's transparent mode (passes audio through unchanged when no echo is detected) and protects near-end speech during double-talk. Best where speech naturalness matters.
    • 'aggressive': Disables near-end speech detection so echo is suppressed even during double-talk; removes ~2 dB more echo but attenuates speech by 3-5 dB.
  • Optional highPassFilter?: boolean

    Apply a high-pass filter on the capture signal to remove DC offset and low-frequency noise that can interfere with the adaptive filter. Defaults to true.

  • Optional residualEchoGate?: boolean

    Apply a post-AEC3 gate that attenuates output when the speaker is active but output is quiet (likely residual echo, not speech). Catches echo the suppressor misses, at the cost of occasional clipping of quiet speech. Defaults to false.

Remarks

Requires macOS 14.2 or later (Core Audio process taps). On older versions, preparing the recorder fails with a configurationNotSupported error.

Generated using TypeDoc