def _group_filter_values(seg, filter_indices, ms_per_input):
    """
    Takes a list of 1s and 0s and returns a list of tuples of the form:
    ['y/n', timestamp].
    """
    ret = []
    for filter_value, (_segment, timestamp) in zip(filter_indices, seg.
        generate_frames_as_segments(ms_per_input)):
        if filter_value == 1:
            if len(ret) > 0 and ret[-1][0] == 'n':
                ret.append(['y', timestamp])
            elif len(ret) > 0 and ret[-1][0] == 'y':
                ret[-1][1] = timestamp
            else:
                ret.append(['y', timestamp])
        elif len(ret) > 0 and ret[-1][0] == 'n':
            ret[-1][1] = timestamp
        elif len(ret) > 0 and ret[-1][0] == 'y':
            ret.append(['n', timestamp])
        else:
            ret.append(['n', timestamp])
    return ret
