Commit cfa0d681 authored by Jan Kiene's avatar Jan Kiene
Browse files

sort input items and patch concatenation order in gen_test.py

parent 0fc4330e
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ def create_experiment_setup(experiment, lab) -> list[Path]:
        input_path = base_path.joinpath("proc_input").joinpath(cat)
        output_path = base_path.joinpath("proc_output").joinpath(suffix)
        bg_noise_path = base_path.joinpath("background_noise").joinpath(
            f"background_noise_{suffix}.wav"
            f"background_noise_{cat}.wav"
        )
        cfg_path = default_cfg_path.parent.joinpath(f"{experiment}{cat}-lab_{lab}.yml")
        cfgs.append(cfg_path)
@@ -124,6 +124,9 @@ def create_experiment_setup(experiment, lab) -> list[Path]:
            cat_num = int(cat[-1])
            if experiment in ["P800-5", "P800-9"] and cat_num >= 3:
                bg_noise_pre_proc_2["snr"] = 15
        if cfg.preprocessing_2.get("concatenate_input", None) is not None:
            cat_num = int[cat[-1]]
            cfg.preprocessing_2["concatenation_order"] = concatenation_order(lab, experiment, cat_num)

        # for MASA, the input format can differ between categories
        if (fmt_for_category := IN_FMT_FOR_MASA_EXPS.get(experiment, None)) is not None:
@@ -160,6 +163,11 @@ def exp_lab_pair(arg):
    return exp, lab


def concatenation_order(lab_id, experiment, category):
    exp_id = f"p0{experiment[-1]}"
    return [f"{lab_id}{exp_id}a{category}s0{i}.wav" for i in range(1, 7)]


if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Generate config files and process files for selecton experiments. Experiment names and lab ids must be given as comma-separated pairs (e.g. 'P800-5,b BS1534-4a,d ...')"
+3 −0
Original line number Diff line number Diff line
@@ -127,6 +127,9 @@ def list_audio(path: str, select_list: list = None) -> list:
            f for f in audio_list if any([pattern in f.stem for pattern in select_set])
        ]

    # sort file list alphanumerically by filenames
    audio_list = sorted(audio_list, key=lambda p: p.name)

    return audio_list