Commit 349bcf6f authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch...

Merge branch '91-metadata-not-copied-over-when-forcing-frame-alignment-padding-for-ism-osba-input' into 'main'

Resolve "Metadata not copied over when forcing frame alignment padding for ISM/OSBA input"

See merge request !180
parents 5e2900c2 bc8c4ee9
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
@@ -575,12 +575,15 @@ def validate_input_files(cfg: TestConfig):
    # always throw an error for ISM (and MASA) input
    if input_format.startswith("ISM") or input_format.startswith("MASA"):
        frame_alignment = "error"
        # NOTE: to override this warning for local testing, simply uncomment the below line
        # this will override the above variable and enable padding for non-aligned files
        # frame_alignment = "padding"

    if frame_alignment == "padding":
        # Create new input directory for padded files
        output_dir = cfg.output_path / "20ms_aligned_files"
        aligned_output_dir = cfg.output_path / "20ms_aligned_files"
        try:
            output_dir.mkdir(exist_ok=False, parents=True)
            aligned_output_dir.mkdir(exist_ok=False, parents=True)
        except FileExistsError:
            raise ValueError(
                "Folder for 20ms aligned files already exists. Please move or delete folder"
@@ -639,24 +642,29 @@ def validate_input_files(cfg: TestConfig):
                        samples=True,
                    )
                    # Write padded data to output directory
                    write(output_dir / item.name, padded_data, fs)
                    write(aligned_output_dir / item.name, padded_data, fs)
                    # Update audio file path in list
                    cfg.items_list[i] = output_dir / item.name
                    cfg.items_list[i] = aligned_output_dir / item.name
                else:
                    raise ValueError(
                        f"Value of key frame_alignment does not match possible options. Value: {frame_alignment}. Options: 'padding', 'ignore', 'warning', 'error'"
                    )
            else:
                if frame_alignment == "padding":
                    copyfile(item, output_dir / item.name)
                    copyfile(item, aligned_output_dir / item.name)
                    # Update audio file path in list
                    cfg.items_list[i] = output_dir / item.name
                else:
                    pass
                    cfg.items_list[i] = aligned_output_dir / item.name

    if frame_alignment == "padding":
        # copy over any metadata files
        [
            copyfile(f, aligned_output_dir / f.name)
            for f in list(cfg.input_path.glob("*.csv"))
            + list(cfg.input_path.glob("*.met"))
        ]

        # Make the output path as the new input path
        cfg.input_path = output_dir
        cfg.input_path = aligned_output_dir


def clean_outputs(cfg: TestConfig) -> None: