def filter_short_segments(segments, threshold):
    """
    Remove segments which duration is smaller than a threshold.
    """
    res = set()
    for seg in segments:
        if seg[1] - seg[0] >= threshold:
            res.add(seg)
    return res