Commit cb8ef03b authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

[fix] object metadata not passed after preprocessing background noise

parent 10e3657e
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -156,12 +156,6 @@ def main(args):
            # save process info to revert it later
            cfg.pre2 = cfg.proc_chains[0]["processes"][0]
            # preprocess background noise
            if (
                hasattr(cfg, "preprocessing")
                and hasattr(cfg.pre2, "background_noise")
                and cfg.pre2.background_noise is not None
                and cfg.pre2.background_noise.get("background_noise_path")
            ):
            preprocess_background_noise(cfg)
            # preprocess 2
            preprocess_2(cfg, logger)
+1 −1
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ class Preprocessing2(Processing):
                raise ValueError(
                    f"Background noise path {self.background_noise.get('background_noise_path')} does not exist"
                )
            # load background noise
            # load preprocessed background noise
            if self.background_noise["background_object"] is not None:
                noise_object = self.background_noise["background_object"]
            else:
+12 −3
Original line number Diff line number Diff line
@@ -569,7 +569,14 @@ def remove_preamble(x, out_fmt, fs, repeat_signal, preamble_len_ms, meta, logger


def preprocess_background_noise(cfg):
    # TODO: add checks and errors for sampling rate and number channels compared to input signals
    if not (
        hasattr(cfg, "preprocessing")
        and hasattr(cfg.pre2, "background_noise")
        and cfg.pre2.background_noise is not None
        and cfg.pre2.background_noise.get("background_noise_path")
    ):
        return

    # create audio objects
    input_audio = audio.fromfile(
        cfg.input["fmt"],
@@ -583,7 +590,10 @@ def preprocess_background_noise(cfg):
    else:
        out_fs = cfg.pre.out_fs
    
    # only consider format conversion, resampling and high-pass filtering
    if hasattr(input_audio, "object_pos"):
        output_audio.object_pos = input_audio.object_pos

    # only apply format conversion, resampling and filtering
    convert(
        input=input_audio,
        output=output_audio,
@@ -593,7 +603,6 @@ def preprocess_background_noise(cfg):
    )

    # save result in cfg
    # cfg.preprocessing_2["background_noise"].update({"background_object": output_audio})
    cfg.proc_chains[0]["processes"][0].background_noise[
        "background_object"
    ] = output_audio