Skip to content

degrade.noise_mixer

Noise-mixing utilities for applying SNR-controlled degradation.

add_noise

Mix speech with noise at a target SNR in dB.

Signature

add_noise(target, noise=None, *, snr_db, noise_type="auto", noise_file=None, sample_rate=None, seed=None)

Args

  • target: Target (clean) waveform
  • noise: Optional in-memory noise waveform
  • snr_db: Target signal-to-noise ratio in dB
  • noise_type: auto, babble, white, colored, or ssn
  • noise_file: Optional noise file path
  • sample_rate: Required for generated noise; optional for file loading
  • seed: Optional RNG seed used for random segment selection

Returns

  • Peak-normalized mixed waveform

Behavior

  • If noise is provided, it is used directly.
  • Else if noise_file is provided, that file is used.
  • Else generated noise is used for white and colored/ssn.
  • babble is file-backed only and cannot be generated by add_noise.
  • If noise_type="auto" and noise_file stem matches bab-tN (for example bab-t8.wav), it is treated as multitalker babble.
  • If noise is longer than target speech, a random equal-length segment is selected before SNR mixing.