Commit 85be2fd0 authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

formatting

parent 93d4dbfe
Loading
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -239,14 +239,18 @@ def generate_ismN_scene(
            # of the reference signal (0-based index)
            if isinstance(scene["shift"][i], str) and "(" in scene["shift"][i]:
                # extract X and i_ref
                match = re.match(r"([+-]?\d*\.?\d+)[\(\[]([+-]?\d+)[\)\]]", scene["shift"][i])
                match = re.match(
                    r"([+-]?\d*\.?\d+)[\(\[]([+-]?\d+)[\)\]]", scene["shift"][i]
                )

                if match:
                    overlap = float(match.group(1))
                    overlap_ref = int(match.group(2))
                else:
                    scene_shift_str = scene["shift"][i]
                    logger.error(f"Unable to parse {scene_shift_str}. The specification of overlap or reference is incorrect!")
                    logger.error(
                        f"Unable to parse {scene_shift_str}. The specification of overlap or reference is incorrect!"
                    )
                    sys.exit(-1)

                # calculate absolute shift of the source signal in seconds
+11 −6
Original line number Diff line number Diff line
@@ -236,14 +236,18 @@ def generate_MC_scene(
            # of the reference signal (0-based index)
            if isinstance(scene["shift"][i], str) and "(" in scene["shift"][i]:
                # extract X and i_ref
                match = re.match(r"([+-]?\d*\.?\d+)[\(\[]([+-]?\d+)[\)\]]", scene["shift"][i])
                match = re.match(
                    r"([+-]?\d*\.?\d+)[\(\[]([+-]?\d+)[\)\]]", scene["shift"][i]
                )

                if match:
                    overlap = float(match.group(1))
                    overlap_ref = int(match.group(2))
                else:
                    scene_shift_str = scene["shift"][i]
                    logger.error(f"Unable to parse {scene_shift_str}. The specification of overlap or reference is incorrect!")
                    logger.error(
                        f"Unable to parse {scene_shift_str}. The specification of overlap or reference is incorrect!"
                    )
                    sys.exit(-1)

                # calculate absolute shift of the source signal in seconds
@@ -418,14 +422,15 @@ def generate_MC_scene(
    # trim the output signal if the total duration exceeds X seconds
    if "duration" in cfg.__dict__:
        # convert from seconds to samples (ensure multiple of 20ms)
        duration = int(
            np.floor(int(cfg.duration * cfg.fs) / frame_len) * frame_len
        )
        duration = int(np.floor(int(cfg.duration * cfg.fs) / frame_len) * frame_len)

        # check if the current length of the output signal exceeds the duration
        if len(y_int.audio) > duration:
            y_int.audio = audioarray.trim(
                y_int.audio, y_int.fs, limits=[0, len(y_int.audio) - duration], samples=True
                y_int.audio,
                y_int.fs,
                limits=[0, len(y_int.audio) - duration],
                samples=True,
            )

    # adjust the loudness of the output signal
+10 −6
Original line number Diff line number Diff line
@@ -227,14 +227,18 @@ def generate_OMASA_scene(
            # of the reference signal (0-based index)
            if isinstance(scene["shift"][i], str) and "(" in scene["shift"][i]:
                # extract X and i_ref
                match = re.match(r"([+-]?\d*\.?\d+)[\(\[]([+-]?\d+)[\)\]]", scene["shift"][i])
                match = re.match(
                    r"([+-]?\d*\.?\d+)[\(\[]([+-]?\d+)[\)\]]", scene["shift"][i]
                )

                if match:
                    overlap = float(match.group(1))
                    overlap_ref = int(match.group(2))
                else:
                    scene_shift_str = scene["shift"][i]
                    logger.error(f"Unable to parse {scene_shift_str}. The specification of overlap or reference is incorrect!")
                    logger.error(
                        f"Unable to parse {scene_shift_str}. The specification of overlap or reference is incorrect!"
                    )
                    sys.exit(-1)

                # calculate absolute shift of the source signal in seconds
@@ -497,13 +501,13 @@ def generate_OMASA_scene(
    # trim the output signal if the total duration exceeds X seconds
    if "duration" in cfg.__dict__:
        # convert from seconds to samples (ensure multiple of 20ms)
        duration = int(
            np.floor(int(cfg.duration * cfg.fs) / frame_len) * frame_len
        )
        duration = int(np.floor(int(cfg.duration * cfg.fs) / frame_len) * frame_len)

        # check if the current length of the output signal exceeds the duration
        if len(y_int.audio) > duration:
            metadata.trim_meta(y_int, limits=[0, len(y_int.audio) - duration], samples=True)
            metadata.trim_meta(
                y_int, limits=[0, len(y_int.audio) - duration], samples=True
            )

    # adjust the loudness of the output signal
    if "loudness" in cfg.__dict__:
+7 −5
Original line number Diff line number Diff line
@@ -224,14 +224,18 @@ def generate_OSBA_scene(
            # of the reference signal (0-based index)
            if isinstance(scene["shift"][i], str) and "(" in scene["shift"][i]:
                # extract X and i_ref
                match = re.match(r"([+-]?\d*\.?\d+)[\(\[]([+-]?\d+)[\)\]]", scene["shift"][i])
                match = re.match(
                    r"([+-]?\d*\.?\d+)[\(\[]([+-]?\d+)[\)\]]", scene["shift"][i]
                )

                if match:
                    overlap = float(match.group(1))
                    overlap_ref = int(match.group(2))
                else:
                    scene_shift_str = scene["shift"][i]
                    logger.error(f"Unable to parse {scene_shift_str}. The specification of overlap or reference is incorrect!")
                    logger.error(
                        f"Unable to parse {scene_shift_str}. The specification of overlap or reference is incorrect!"
                    )
                    sys.exit(-1)

                # calculate absolute shift of the source signal in seconds
@@ -483,9 +487,7 @@ def generate_OSBA_scene(
    # trim the output signal if the total duration exceeds X seconds
    if "duration" in cfg.__dict__:
        # convert from seconds to samples (ensure multiple of 20ms)
        duration = int(
            np.floor(int(cfg.duration * cfg.fs) / frame_len) * frame_len
        )
        duration = int(np.floor(int(cfg.duration * cfg.fs) / frame_len) * frame_len)

        # check if the current length of the output signal exceeds the duration
        if len(y.audio) > duration:
+7 −5
Original line number Diff line number Diff line
@@ -228,14 +228,18 @@ def generate_sba_scene(
            # of the reference signal (0-based index)
            if isinstance(scene["shift"][i], str) and "(" in scene["shift"][i]:
                # extract X and i_ref
                match = re.match(r"([+-]?\d*\.?\d+)[\(\[]([+-]?\d+)[\)\]]", scene["shift"][i])
                match = re.match(
                    r"([+-]?\d*\.?\d+)[\(\[]([+-]?\d+)[\)\]]", scene["shift"][i]
                )

                if match:
                    overlap = float(match.group(1))
                    overlap_ref = int(match.group(2))
                else:
                    scene_shift_str = scene["shift"][i]
                    logger.error(f"Unable to parse {scene_shift_str}. The specification of overlap or reference is incorrect!")
                    logger.error(
                        f"Unable to parse {scene_shift_str}. The specification of overlap or reference is incorrect!"
                    )
                    sys.exit(-1)

                # calculate absolute shift of the source signal in seconds
@@ -389,9 +393,7 @@ def generate_sba_scene(
    # trim the output signal if the total duration exceeds X seconds
    if "duration" in cfg.__dict__:
        # convert from seconds to samples (ensure multiple of 20ms)
        duration = int(
            np.floor(int(cfg.duration * cfg.fs) / frame_len) * frame_len
        )
        duration = int(np.floor(int(cfg.duration * cfg.fs) / frame_len) * frame_len)

        # check if the current length of the output signal exceeds the duration
        if len(y.audio) > duration:
Loading