import json


def create_label_json(path, labels=[], start_time=None):
    """ Write a json file from a list of labels
    Parameters
    ----------
        path: str
            Path of the future json file.
        labels: list
            List of labels, each label is a dictionary with keys 'id', 'start', 'end' and 'annotation'
        start_time: float
            Start time of audio extract in seconds
    """
    data_dict = []

    for label in labels:
        data_dict.append({
            'id': 'none',
            'start': label['start'] - start_time,
            'end': label['end'] - start_time,
            'annotation': 'bird'
        })

    with open(path, 'w') as outfile:
        json.dump(data_dict, outfile)

    return None