Commit 67085bed authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

formatting

parent 89477466
Loading
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -40,7 +40,11 @@ from ivas_processing_scripts.constants import (
    LOGGER_FORMAT,
    LOGGER_SUFFIX,
)
from ivas_processing_scripts.generation import config, process_ism_items, process_stereo_items
from ivas_processing_scripts.generation import (
    config,
    process_ism_items,
    process_stereo_items,
)
from ivas_processing_scripts.utils import create_dir


+11 −9
Original line number Diff line number Diff line
@@ -33,13 +33,14 @@
import csv
import logging
import os
import numpy as np
from math import floor
from pathlib import Path

from ivas_processing_scripts.generation import config
import numpy as np

from ivas_processing_scripts.audiotools import audio, audiofile
from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness
from ivas_processing_scripts.generation import config

SEED_RANDOM_NOISE = 0

@@ -99,7 +100,6 @@ def generate_ism_items(

        # repeat for all source files
        for i in range(N_sources):
        
            # parse parameters from the scene description
            source_file = np.atleast_1d(scene["source"])[i]
            source_azi = np.atleast_1d(scene["azimuth"])[i]
@@ -110,7 +110,9 @@ def generate_ism_items(
            )

            # read source file
            x = audio.fromfile("MONO", os.path.join(cfg.input_path, source_file), fs=cfg.fs)
            x = audio.fromfile(
                "MONO", os.path.join(cfg.input_path, source_file), fs=cfg.fs
            )

            # get the number of frames (multiple of 20ms)
            N_frames = int(len(x.audio) / x.fs * 50)
+39 −36
Original line number Diff line number Diff line
@@ -33,15 +33,16 @@
import csv
import logging
import os
import numpy as np
from copy import copy
from math import floor
from pathlib import Path

from ivas_processing_scripts.generation import config
import numpy as np

from ivas_processing_scripts.audiotools import audio, audiofile
from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness
from ivas_processing_scripts.audiotools.wrappers.reverb import reverb_stereo
from ivas_processing_scripts.generation import config

SEED_RANDOM_NOISE = 0

@@ -99,7 +100,7 @@ def generate_stereo_items(
        source_IR = np.atleast_1d(scene["IR"])

        # read the overlap length
        if 'overlap' in scene.keys():
        if "overlap" in scene.keys():
            source_overlap = float(scene["overlap"])
        else:
            source_overlap = 0.0
@@ -110,18 +111,20 @@ def generate_stereo_items(
            source_file = np.atleast_1d(scene["source"])[i]
            IR_file = np.atleast_1d(scene["IR"])[i]

            logger.info(
                f"Convolving {source_file} with {source_IR}"
            )
            logger.info(f"Convolving {source_file} with {source_IR}")

            # read source file
            x = audio.fromfile("MONO", os.path.join(cfg.input_path, source_file), fs=cfg.fs)
            x = audio.fromfile(
                "MONO", os.path.join(cfg.input_path, source_file), fs=cfg.fs
            )

            # get the number of frames (multiple of 20ms)
            N_frames = int(len(x.audio) / x.fs * 50)

            # read the IR file
            IR = audio.fromfile("STEREO", os.path.join(cfg.IR_path, IR_file), fs=cfg.IR_fs)
            IR = audio.fromfile(
                "STEREO", os.path.join(cfg.IR_path, IR_file), fs=cfg.IR_fs
            )

            # convolve with stereo IR
            x_rev = reverb_stereo(x, IR)
@@ -209,9 +212,9 @@ def generate_stereo_items(
        if add_low_level_random_noise:
            # create uniformly distributed noise between -4 and 4
            np.random.seed(SEED_RANDOM_NOISE)
            noise = np.random.randint(
                low=-4, high=5, size=y.audio.shape
            ).astype("float")
            noise = np.random.randint(low=-4, high=5, size=y.audio.shape).astype(
                "float"
            )

            # superimpose
            y.audio += noise
+1 −1

File changed.

Contains only whitespace changes.

+1 −1

File changed.

Contains only whitespace changes.