def generate_mix_list(cwav_list, nwav_list, output_list, snr_range=[-5,5]):
    '''
        cwav_list: include clean wav path list
        nwav_list: include noise wav path list
        output_list: output cwav path, nwav_path, start_time, scale snr
    '''
    noise_lists = []
    
    with open(nwav_list) as nfid:
        for line in nfid:
            noise_lists.append(line.strip().split()[0])
    
    noise_lists_length = len(noise_lists)
    with open(cwav_list) as cfid:
        with open(output_list, 'w') as outfid:
            for line in cfid:
                cpath = line.strip().split()[0]
                cwav_len = read(cpath).shape[0]
                while True:
                    nid = np.random.randint(noise_lists_length)
                    nwav_len = read(noise_lists[nid]).shape[0]
                    if nwav_len < cwav_len//2:
                        continue
                    else:
                        break
                if cwav_len < nwav_len:
                    stime = np.random.randint(nwav_len-cwav_len)
                elif cwav_len == nwav_len:
                    stime = 0
                elif cwav_len > nwav_len:
                    stime = -1

                if isinstance(snr_range, list):
                    snr = np.random.uniform(snr_range[0], snr_range[1])
                else:
                    snr = snr_range
                t = np.random.normal() * 0.5 + 0.9
                lower=0.3
                upper=0.99
                if t < lower or t > upper:
                    t = np.random.uniform(lower, upper) 
                scale = t
                outfid.writelines(cpath+' '+ noise_lists[nid] + ' ' + str(stime)+' {:.3f}'.format(snr)+' {:.3f}'.format(scale)+'\n')
                sys.stdout.flush()

        cwav_list: include clean wav path list
        nwav_list: include noise wav path list
        output_list: output cwav path, nwav_path, start_time, scale snr
    
train/speech_separation/utils/add_noise.py