def _LookForDropoutsInWindow(data_array, samp_freq, window_offset,
                             silence_threshold, min_silence_len_secs):
  """Get silence periods inside the current window.

  This function returns a list of periods, for which the wave file contains
  silence. Only silence periods longer then MIN_SILENCE_LENGTH_MS are returned.
  All values in the range of +/- silence_threshold are interpreted as silence.

  Args:
    data_array: the window with the values.
    samp_freq: sampling frequency of the signal in Hz as integer.
    window_offset: the number of samples from start of the wave file until the
      beginning of the current window.
    silence_threshold: (float) Lowest volume level which is not interpreted as
      silence.
    min_silence_len_secs: (float) minimum length of silence, so that it is
      interpreted as such.
  Returns:
    (list of tuple(float, float)) timestamp of beginning and end of silence.
  """
  ret = []
  dropout_counter = -1
  current_dropout = None

  dropout_min_samples = min_silence_len_secs * samp_freq

  for index, value in enumerate(data_array):
    if abs(value) < silence_threshold:
      dropout_counter += 1
      # Dropout detected
      if dropout_counter > dropout_min_samples and not current_dropout:
        timestamp = float(window_offset + index - dropout_counter) / samp_freq
        current_dropout = timestamp
    # Dropout ended
    else:
      dropout_counter = -1
      if current_dropout:
        timestamp = float(window_offset + index) / samp_freq
        ret.append((current_dropout, timestamp))
        dropout_counter = -1
        current_dropout = None

  # Special case: Dropout extends beyond window range
  if current_dropout:
    timestamp = float(window_offset + len(data_array) - 1) / samp_freq
    ret.append((current_dropout, timestamp))

  return ret