def apodize(data, ms=5, rate=44100):
 hw_size = int(min((rate // (1000 / ms)), (len(data) // 15)))
 hamming_window = np.hamming(((2 * hw_size) + 1))
 data[:hw_size] *= hamming_window[:hw_size]
 data[(- hw_size):] *= hamming_window[(- hw_size):]
 return data

def apodize ( data , ms = 5 , rate = 44100 ) : hw_size = int ( min ( ( rate // ( 1000 / ms ) ) , ( len ( data ) // 15 ) ) ) hamming_window = np . hamming ( ( ( 2 * hw_size ) + 1 ) ) data [ : hw_size ] *= hamming_window [ : hw_size ] data [ ( - hw_size ) : ] *= hamming_window [ ( - hw_size ) : ] return data
apply a hamming window to reduce a sounds click onset / offset .