audiomentations icon indicating copy to clipboard operation
audiomentations copied to clipboard

Idea: Rename AddBackgroundNoise?

Open iver56 opened this issue 2 years ago • 1 comments

I feel like it isn't limited to adding specifically background noise - it could be any type of noise or actually any audio (it doesn't have to be noise although that is a common thing to do)

Any suggestions for a better name? AddNoise? AddNoiseFromFiles? MixInSoundFile?

iver56 avatar Sep 16 '22 07:09 iver56

How about AddExternalNoise?

atamazian avatar Mar 03 '23 17:03 atamazian

Simply renaming might be confusing in some scenarios. In my opinion, repeat of sound is typical for background noise only.

https://github.com/iver56/audiomentations/blob/63a2eb7a75a0a5c2627bc5312d13ef789644a94a/audiomentations/augmentations/add_background_noise.py#L229

    # Repeat the sound if it shorter than the input sound
    num_samples = len(samples)
    while len(noise_sound) < num_samples:
        noise_sound = np.concatenate((noise_sound, noise_sound))

    if len(noise_sound) > num_samples:
        noise_sound = noise_sound[0:num_samples]

    # Return a mix of the input sound and the background noise sound
    return samples + noise_sound

If the rename is considered to make it more general, this functionality could be controlled by a boolean parameter like noise_repeat. For non-background noises, mixing of audio should only be allowed for same length files.

sudhanshu22gupta avatar Mar 11 '24 10:03 sudhanshu22gupta

Ok

iver56 avatar Mar 11 '24 12:03 iver56