Defining a dynamic threshold for active noise reduction

Is there any way to define a dynamic threshold for filtering noise in python? I am trying to achieve active noise reduction using python. What I want to achieve is that everything that is below the threshold will be filtered (this will be the ones classified as unwanted noise). On the other hand, everything above the threshold (i.e. voice) will be untouched. Is there already an available script for this kind of idea?