Find large number of consecutive values fulfilling condition in a numpy array

后端 未结 8 1568
悲&欢浪女
悲&欢浪女 2020-12-05 00:53

I have some audio data loaded in a numpy array and I wish to segment the data by finding silent parts, i.e. parts where the audio amplitude is below a certain threshold over

8条回答
  •  生来不讨喜
    2020-12-05 01:26

    I know I'm late to the party, but another way to do this is with 1d convolutions:

    np.convolve(sig > threshold, np.ones((cons_samples)), 'same') == cons_samples
    

    Where cons_samples is the number of consecutive samples you require above threshold

提交回复
热议问题