This is my first question here in DSP StackExchange and honestly speaking I don't have any experience in this field, but one of the school project I'm currently working in is building an application that removes background noise from audio recordings in Python.

Moreover, according to a post (which I will attach below) from StackOverflow, it is recommended that I should learn about the noises I want to remove in order to determine their strategies. Like I mentioned earlier, I don't really know much about DSP and can't really determine the types and characteristics of the noise I want to remove apart from the likely source that it came from, and the resources online is very confusing and differing from each other.

For simplicity, let's say I want to remove noise of these types: Rain noise, traffic noise, fan noise and construction noise. What features from them do I need to know in order to determine a strategy to remove them ? The post in question: https://stackoverflow.com/questions/45118109/noise-reduction-in-an-audio-file-using-python

Thank you.


2 Answers 2


So, first of all, a filter in signal processing is analogous to a filter that you'd use on liquids. A coffee filter passes through the stuff you want (liquid coffee), and holds back the stuff you don't want (coffee grounds). It does this because the coffee grounds are bigger than water molecules, and all those yummy flavor molecules (not to mention caffeine molecules).

Similarly, some industrial operation might be making a slurry that's contaminated with particulates like gravel or whatever. Then you'd use a filter with larger holes to hold back the particulates, while letting through whatever size particles are in the slurry.

One of the early discovery in the study of viruses was that if you ran water through a ceramic filter (basically unglazed clay jugs), then the weird unknown infectious agent that they couldn't see with the microscopes of the time wouldn't pass through the filter -- so they deduced that it was smaller than they could see, but still larger than water molecules.

The point of all these physical analogies is that you have to design the filter to match the noise, and in the case of signal processing, you often have to choose a filter that degrades your "signal" somewhat, while (hopefully) eliminating the noise more.

In general, the categories you've chosen are all difficult ones. Depending on what you're really doing, it may be quite profitable to start with some sound-mixing app (like Audacity) and just experiment with the available filters and see what sounds best -- then translate that into filters in your Python code. For an undergrad project, that may be more than enough.

Here are some thoughts I have on each one of the noise types you're suggesting:

Rain noise:

This is going to sound a lot like white noise. There's not much you can do here but to identify the spectrum of the sound you want to let through, and filter out everything else. I.e., if you've got someone talking in a rainstorm, and the recording is high-fidelity, with frequencies from 50Hz to 15kHz being passed through, you might try passing just 300-3000Hz. That should make the speech more intelligible, but it'll sound like they're talking on a telephone.

If they're singing in the rain, then you'd probably need some sort of an artificial intelligence whiz-bang filter that identifies what their voice is at any moment and filters out the rest. It'll be (A) imperfect, and (B) difficult (the stuff of a PhD thesis, basically, so you want to search one out and use it, not make your own).

traffic noise

Similar answer to rain noise, although depending on the character of the traffic you could maybe identify individual features (tires on pavement swooshing by) and filter them out dynamically.

fan noise

This is definitely going to be white noise, much like traffic noise.

construction noise

In overall character, this is going to be more like traffic noise, except that there'll be more bangs and impulsive noises. A filter that's good with white noise plus a "pop" filter may help here.


What features from them do I need to know in order to determine a strategy to remove them ?

Likely the most important feature you need to know about these noises is their spectral content. In other words, you need to know how the energy of each of noise is spread out across different frequencies.

If you have a recording of the noise you want to remove, you can find the spectral content directly using a software program like Audacity by taking the FFT of the recording. In Audacity you use Analyze->Plot Spectrum. If you have the data stored in an array in Python you can use numpy.fft.fft() or scipy.signal.fft(). Theres probably ways of doing this in Python directly with compressed audio files but I’m not familiar with any.

Once you know the spectrum of the noises you want to remove, you can design a filter or multiple filters that will remove most of the noise when you pass the audio data through them. There’s a lot of information on the internet about designing and using filters in Python so hopefully this takes you far enough.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.