title: Extract subarrays of numpy array whose values are above a threshold
body: <p>I have a sound signal, imported as a numpy array and I want to cut it into chunks of numpy arrays. However, I want the chunks to contain only elements above a threshold. For example:</p>
  
  <pre><code>threshold = 3
  signal = [1,2,6,7,8,1,1,2,5,6,7]
  </code></pre>
  
  <p>should output two arrays </p>
  
  <pre><code>vec1 = [6,7,8]
  vec2 = [5,6,7]
  </code></pre>
  
  <p>Ok, the above are lists, but you get my point. </p>
  
  <p>Here is what I tried so far, but this just kills my RAM</p>
  
  <pre><code>def slice_raw_audio(audio_signal, threshold=5000):
  
      signal_slice, chunks = [], []
  
      for idx in range(0, audio_signal.shape[0], 1000):
          while audio_signal[idx] &gt; threshold:
              signal_slice.append(audio_signal[idx])
           chunks.append(signal_slice)
      return chunks
  </code></pre>