Search code examples
pythonaudio

noise reduction using empty noise profile


I'm trying to reduce noise from an recorded voice file. I am using python noise reduce and making some tests to optimise. As the noise is permanent and relatively steady I was expecting to use a sound without voice as a filter to reversely apply it to the recorded voices.

The thing is I don't find any difference between the two versions so I was wonderning if I am making it wrong of if it is just the process that cannot do better from one version to another. Using

from scipy.io import wavfile
import noisereduce as nr

# Using a profile
rate, data = wavfile.read("thisisatest.wav")
prof_rate, noise_profile = wavfile.read("empty_noise.wav")
reduced_noise = nr.reduce_noise(y=data, sr=rate, y_noise=noise_profile)
wavfile.write("not_noisy_anymore_profile.wav", rate, reduced_noise)

#Classic way
rate, data = wavfile.read("thisisatest.wav")
reduced_noise = nr.reduce_noise(y=data, sr=rate)
wavfile.write("not_noisy_anymore.wav", rate, reduced_noise)

Has anyone been using this ?


Solution

  • As the docs for the library you use say, y_noise is only used if stationary=True.

        y_noise : np.ndarray [shape=(# frames,) or (# channels, # frames)], real-valued
            noise signal to compute statistics over (only for stationary noise reduction).
        stationary : bool, optional
            Whether to perform stationary, or non-stationary noise reduction, by default False
    

    You're not passing stationary=True, so y_noise is ignored.