

def detect_silence(audio_segment, min_silence_len=1000, silence_thresh=(- 16)):
    seg_len = len(audio_segment)
    if (seg_len < min_silence_len):
        return []
    silence_thresh = (db_to_float(silence_thresh) * audio_segment.max_possible_amplitude)
    silence_starts = []
    slice_starts = (seg_len - min_silence_len)
    for i in range((slice_starts + 1)):
        audio_slice = audio_segment[i:(i + min_silence_len)]
        if (audio_slice.rms < silence_thresh):
            silence_starts.append(i)
    if (not silence_starts):
        return []
    silent_ranges = []
    prev_i = silence_starts.pop(0)
    current_range_start = prev_i
    for silence_start_i in silence_starts:
        if (silence_start_i != (prev_i + 1)):
            silent_ranges.append([current_range_start, (prev_i + min_silence_len)])
            current_range_start = silence_start_i
        prev_i = silence_start_i
    silent_ranges.append([current_range_start, (prev_i + min_silence_len)])
    return silent_ranges

dataset/ETHPy150Open jiaaro/pydub/pydub/silence.py detect_silence/original