'Make elements of array silent [closed]

I have 1 array which contains sound data. It has elements like -100,200,8.... .

I want to make thus elements silent which are less than 50. Can anyone help me in this

Like array = np.where(element < 50, silent)



Solution 1:[1]

Supposing you have numpy.array, you can use np.where. You should use np.abs to turn a value within (-50, 50) into 0.

import numpy as np
sound = np.array([-100, 200, 8])
simply_denoised_sound = np.where(np.abs(sound) < 50, 0, sound)
print(simply_denoised_sound) # [-100  200    0]

Solution 2:[2]

You can use filter to return a copy with elements removed from an array:

list(filter(lambda e: e < 50, array))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Nate