def nonzero_segments(f0):
    """Find nonzero segments

    Args:
        f0 (np.ndarray): array of f0

    Returns:
        list: list of (start, end)
    """
    vuv = f0 > 0
    started = False
    s, e = 0, 0
    segments = []
    for idx in range(len(f0)):
        if vuv[idx] > 0 and not started:
            started = True
            s = idx
        elif started and (vuv[idx] <= 0):
            e = idx
            started = False
            segments.append((s, e))
        else:
            pass
    return segments