import csv


def read_strong_csv(strong_meta_csv_path):
    """Read strongly labelled ground truth csv file. 
    
    Args:
      strong_meta_csv_path: str

    Returns: 
      meta_dict: {'a.wav': [{'onset': 3.0, 'offset': 5.0, 'label': 'Bus'},
                            {'onset': 4.0, 'offset': 7.0, 'label': 'Train'}
                            ...],
                  ...}
    """
    with open(strong_meta_csv_path, 'r') as fr:
        reader = csv.reader(fr, delimiter='\t')
        lines = list(reader)
        
    meta_dict = {}
    for line in lines:
        """line: ['-5QrBL6MzLg_60.000_70.000.wav', '0.917', '2.029', 'Train horn']"""
        [audio_name, onset, offset, label] = line
        meta = {'onset': onset, 'offset': offset, 'label': label}
        if audio_name in meta_dict:
            meta_dict[audio_name].append(meta)
        else:
            meta_dict[audio_name] = [meta]
        
    return meta_dict