def trim_silence(feats, labels, start_sec=0.05, end_sec=0.1, shift_sec=0.005):
    """Trim silence from input features.

    Args:
        feats (np.ndarray): input features
        labels (np.ndarray): labels
        start_sec (float, optional): start time of the trim
        end_sec (float, optional): end time of the trim
        shift_sec (float, optional): shift of the trim

    Returns:
        np.ndarray: trimmed features
    """
    assert "sil" in labels.contexts[0] and "sil" in labels.contexts[-1]
    start_frame = int(labels.start_times[1] / 50000)
    end_frame = int(labels.end_times[-2] / 50000)
    start_frame = max(0, start_frame - int(start_sec / shift_sec))
    end_frame = min(len(feats), end_frame + int(end_sec / shift_sec))
    feats = feats[start_frame:end_frame]
    return feats