Xun
Xun

Reputation: 53

How to add noise to audiosegment using pydub?

I am very new to signal processing so apologies for the simplicity! I would like to use pydub to add noise to a sound clip. I know pydub has several generator functions for noise and an overlay audio one. Is overlaying the generated noise segment over the sound clip equivalent to

sound = some signal (possibly raw data?)

noise = np.random.normal(0,1,100)

result = sound + noise ?

Upvotes: 1

Views: 2673

Answers (1)

Jiaaro
Jiaaro

Reputation: 76918

You’ll need to overlay the noise — something like:

from pydub import AudioSegment
from pydub.generators import WhiteNoise

sound = AudioSegment.from_file(...)
noise = WhiteNoise().to_audio_segment(duration=len(sound))

combined = sound.overlay(noise)

Upvotes: 3

Related Questions