示例#1
0
    out_tsv = osp.join(out_tsv_folder, "500ms.tsv")
    post_process_txt_labels(out_folder_500,
                            output_folder=out_folder_500,
                            output_tsv=out_tsv)

    # Generate 2 variants of this dataset
    jams_to_modify = glob.glob(osp.join(out_folder_500, "*.jams"))
    # Be careful, if changing the values of the added onset value,
    # you maybe want to rerun the post_processing_annotations to be sure there is no inconsistency

    # 5.5s onset files
    out_folder_5500 = osp.join(base_out_folder, "5500ms")
    add_onset = 5.0
    modif_onset_5s = functools.partial(modify_fg_onset,
                                       slice_seconds=add_onset)
    modify_jams(jams_to_modify, modif_onset_5s, out_folder_5500)
    # we also need to generate a new DataFrame with the right values
    df = pd.read_csv(out_tsv, sep="\t")
    df["onset"] += add_onset
    df["offset"] = df["offset"].apply(lambda x: min(x, add_onset))
    df.to_csv(
        osp.join(out_tsv_folder, "5500ms.tsv"),
        sep="\t",
        float_format="%.3f",
        index=False,
    )

    # 9.5s onset files
    out_folder_9500 = osp.join(base_out_folder, "9500ms")
    add_onset = 9.0
    modif_onset_5s = functools.partial(modify_fg_onset,
示例#2
0
    pitch_max = 3.0

    time_stretch_dist = 'uniform'
    time_stretch_min = 1
    time_stretch_max = 1

    out_folder_ls_30 = osp.join(out_folder, "ls_30dB")
    create_folder(out_folder_ls_30)
    sg.generate(n_soundscapes, out_folder_ls_30, min_events, max_events, labels=('choose', []),
                source_files=('choose', []), sources_time=(source_time_dist, source_time),
                events_start=(evt_time_dist, evt_time_mean, evt_time_std, evt_time_min, evt_time_max),
                events_duration=(event_duration_dist, event_duration_min, event_duration_max),
                snrs=('const', 30), pitch_shifts=('uniform', -3.0, 3.0), time_stretches=('uniform', 1, 1),
                txt_file=True)

    rm_high_polyphony(out_folder_ls_30, 3)
    post_process_txt_labels(out_folder_ls_30, output_folder=out_folder_ls_30, output_tsv=args.out_tsv,
                            background_label=True)

    list_jams = glob.glob(osp.join(out_folder_ls_30, "*.jams"))
    # We create the same dataset with different background SNR
    # Be careful, 15 means the background SNR is 15,
    # so the foreground background snr ratio is between -9dB and 15dB
    out_folder_ls_15 = osp.join(out_folder, "ls_15dB")
    modify_jams(list_jams, change_snr, out_folder_ls_15, db_change=-15)

    # Same for 0dB FBSNR, from original fbsnr [6;30]dB, we go to [-24;0]dB FBSNR
    out_folder_ls_0 = osp.join(out_folder, "ls_0dB")
    modify_jams(list_jams, change_snr, out_folder_ls_15, db_change=-30)

示例#3
0
def test_generate_new_bg_snr_files():
    out_dir = os.path.join(absolute_dir_path, "generated", "new_snr")
    list_jams = glob.glob(os.path.join(absolute_dir_path, "material",
                                       "*.jams"))
    func_modify_snr15 = functools.partial(change_snr, db_change=15)
    modify_jams(list_jams, func_modify_snr15, out_dir)
示例#4
0
    post_process_txt_labels(out_folder_30,
                            output_folder=out_folder_30,
                            output_tsv=out_tsv)

    # ###
    # Generate variation of the dataset by varying the FBSNR
    # ###
    # We create the same dataset with different background SNR
    # The foreground background snr ratio is between 0dB and 24dB (see utils snr_min (6dB) and snr_max (30dB))
    out_folder_24 = osp.join(out_folder, "24dB")
    create_folder(out_folder_24)

    jams_to_modify = glob.glob(osp.join(out_folder_30, "*.jams"))
    # Put FBSNR to [0;24] range so reducing of 6 compared to [6;30]
    minus_6_snr = functools.partial(change_snr, db_change=-6)
    new_jams24 = modify_jams(jams_to_modify, minus_6_snr, out_folder_24)
    generate_files_from_jams(new_jams24, out_folder_24, out_folder_24)

    # Same for 15
    out_folder_15 = osp.join(out_folder, "15dB")
    create_folder(out_folder_15)
    minus_15_snr = functools.partial(change_snr, db_change=-15)
    new_jams15 = modify_jams(jams_to_modify, minus_15_snr, out_folder_15)
    generate_files_from_jams(new_jams15, out_folder_15, out_folder_15)

    out_folder_0 = osp.join(out_folder, "0dB")
    create_folder(out_folder_0)
    minus_30_snr = functools.partial(change_snr, db_change=-30)
    new_jams0 = modify_jams(jams_to_modify, minus_30_snr, out_folder_0)
    generate_files_from_jams(new_jams0, out_folder_0, out_folder_0)
示例#5
0
            # Replace duration line, needed to do the del add because of the type of data
            new_obs = jams_obj["annotations"][0].data[cnt]._replace(
                duration=time_trunc)
            del jams_obj["annotations"][0].data[cnt]
            jams_obj["annotations"][0].data.add(new_obs)

    return jams_obj


if __name__ == '__main__':
    base_soundbank = osp.join("..", "..", "synthetic")

    for subset in ["train", "eval"]:
        soundbank_path = osp.join(base_soundbank, "audio", subset, "soundbank")
        fg_folder = osp.join(soundbank_path, "foreground/")
        bg_folder = osp.join(soundbank_path, "background")

        dataset_path = osp.join("..", "..", "dataset")
        jams_folder = osp.join(dataset_path, "audio", subset,
                               f"one_event_generated")
        outfolder = osp.join(dataset_path, "audio", subset,
                             f"one_event_generated_200ms")
        outtsv = osp.join(dataset_path, "metadata", subset,
                          f"one_event_generated_200ms.tsv")

        list_jams = glob.glob(os.path.join(jams_folder, "*.jams"))
        new_jams = modify_jams(list_jams, get_part_audio, outfolder)

        generate_files_from_jams(new_jams, outfolder)
        generate_tsv_from_jams(new_jams, outtsv)