Suppressing audio with Python

highcenburg

Vicente G. Reyes

Posted on February 27, 2023

Suppressing audio with Python

In my previous article, I separated the vocals from a track using librosa. I wasn't happy about the outcome so I did a little googling and found another audio library from python called noisereduce. In this article, I'll show you how I solved my problem with a muddy audio which was removed using librosa.

You can find the jupyter notebook here

# Read audio
data, samplerate = sf.read('Vocals.wav')
# reduce noise
y_reduced_noise = nr.reduce_noise(y=data, sr=samplerate)
# save audio
sf.write('Vocals_reduced.wav', y_reduced_noise, samplerate, subtype="PCM_24")
# load and play audio
data, samplerate = librosa.load('Vocals_reduced.wav')
ipd.Audio('Vocals_reduced.wav')
Enter fullscreen mode Exit fullscreen mode

We first read the audio's y and x axis with a data and samplerate variable with soundfile. Then reduce the noise with the reduce_noise() function of noisereduce which we then pass in the data and samplerate arguments for the function. Next, we write the new audio with soundfile's write() function and pass in the reduced noise variable, samplerate to get a .wav output. Finally, we load and play the audio with librosa's load() function and IPython's Audio() function.

💖 💪 🙅 🚩
highcenburg
Vicente G. Reyes

Posted on February 27, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related