Loading ivas_processing_scripts/audiotools/wrappers/reverb.py +4 −5 Original line number Diff line number Diff line Loading @@ -30,11 +30,10 @@ # the United Nations Convention on Contracts on the International Sales of Goods. # import os.path from copy import copy from pathlib import Path from tempfile import TemporaryDirectory from typing import Optional, Union from typing import Optional import numpy as np from scipy.fft import fft Loading Loading @@ -91,7 +90,7 @@ def reverb( tmp_input.fs = IR.fs # write input audio signal to temporary file in .pcm format tmp_input_file = tmp_dir.joinpath(f"tmp_reverbIn.pcm") tmp_input_file = tmp_dir.joinpath("tmp_reverbIn.pcm") write(tmp_input_file, tmp_input.audio, tmp_input.fs) # down-scale IR to prevent saturation Loading @@ -101,7 +100,7 @@ def reverb( # write IR to temporary file in .pcm format # note: the reverb tool expects 32b float format tmp_IR_file = tmp_dir.joinpath(f"tmp_IR.pcm") tmp_IR_file = tmp_dir.joinpath("tmp_IR.pcm") write(tmp_IR_file, IR.audio.astype(np.float32), IR.fs, dtype=np.float32) # set up the 'reverb' command line Loading @@ -114,7 +113,7 @@ def reverb( cmd.extend(["-align", str(align)]) # append temporary filenames tmp_output_file = tmp_dir.joinpath(f"tmp_reverbOut.pcm") tmp_output_file = tmp_dir.joinpath("tmp_reverbOut.pcm") cmd.extend([tmp_input_file, tmp_IR_file, tmp_output_file]) # run the 'reverb' command Loading ivas_processing_scripts/generation/config.py +1 −0 Original line number Diff line number Diff line Loading @@ -123,3 +123,4 @@ class TestConfig: # Report missing keys to the user if MISSING_KEYS: raise KeyError(f"The following key(s) must be specified : {MISSING_KEYS}") ivas_processing_scripts/generation/process_ism_items.py +0 −5 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import csv import logging import os from math import floor from pathlib import Path import numpy as np Loading Loading @@ -117,10 +116,6 @@ def generate_ism_items( # get the number of frames (multiple of 20ms) N_frames = int(len(x.audio) / x.fs * 50) # trim the source signal to align to 20ms boundary # N_trim = int(N_frames * x.fs / 50) # x.audio = x.audio[:N_trim] # adjust the level of the source file _, scale_factor = get_loudness(x, cfg.loudness, "MONO") x.audio *= scale_factor Loading ivas_processing_scripts/generation/process_stereo_items.py +4 −11 Original line number Diff line number Diff line Loading @@ -30,14 +30,10 @@ # the United Nations Convention on Contracts on the International Sales of Goods. # import csv import logging import os from copy import copy from math import floor from pathlib import Path import numpy as np from math import floor from ivas_processing_scripts.audiotools import audio, audiofile from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness Loading Loading @@ -118,9 +114,6 @@ def generate_stereo_items( "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 Loading Loading @@ -200,16 +193,16 @@ def generate_stereo_items( pre = np.zeros((N_pre, y.audio.shape[1])) y.audio = np.concatenate([pre, y.audio]) if postamble != 0.0: if cfg.postamble != 0.0: # ensure that post-mable is a multiple of 20ms N_post = int(floor(postamble * 50) / 50 * y.fs) N_post = int(floor(cfg.postamble * 50) / 50 * y.fs) # append all-zero postamble to all sources post = np.zeros((N_post, y.audio.shape[1])) y.audio = np.concatenate([y.audio, post]) # add random noise if add_low_level_random_noise: if cfg.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( Loading Loading
ivas_processing_scripts/audiotools/wrappers/reverb.py +4 −5 Original line number Diff line number Diff line Loading @@ -30,11 +30,10 @@ # the United Nations Convention on Contracts on the International Sales of Goods. # import os.path from copy import copy from pathlib import Path from tempfile import TemporaryDirectory from typing import Optional, Union from typing import Optional import numpy as np from scipy.fft import fft Loading Loading @@ -91,7 +90,7 @@ def reverb( tmp_input.fs = IR.fs # write input audio signal to temporary file in .pcm format tmp_input_file = tmp_dir.joinpath(f"tmp_reverbIn.pcm") tmp_input_file = tmp_dir.joinpath("tmp_reverbIn.pcm") write(tmp_input_file, tmp_input.audio, tmp_input.fs) # down-scale IR to prevent saturation Loading @@ -101,7 +100,7 @@ def reverb( # write IR to temporary file in .pcm format # note: the reverb tool expects 32b float format tmp_IR_file = tmp_dir.joinpath(f"tmp_IR.pcm") tmp_IR_file = tmp_dir.joinpath("tmp_IR.pcm") write(tmp_IR_file, IR.audio.astype(np.float32), IR.fs, dtype=np.float32) # set up the 'reverb' command line Loading @@ -114,7 +113,7 @@ def reverb( cmd.extend(["-align", str(align)]) # append temporary filenames tmp_output_file = tmp_dir.joinpath(f"tmp_reverbOut.pcm") tmp_output_file = tmp_dir.joinpath("tmp_reverbOut.pcm") cmd.extend([tmp_input_file, tmp_IR_file, tmp_output_file]) # run the 'reverb' command Loading
ivas_processing_scripts/generation/config.py +1 −0 Original line number Diff line number Diff line Loading @@ -123,3 +123,4 @@ class TestConfig: # Report missing keys to the user if MISSING_KEYS: raise KeyError(f"The following key(s) must be specified : {MISSING_KEYS}")
ivas_processing_scripts/generation/process_ism_items.py +0 −5 Original line number Diff line number Diff line Loading @@ -34,7 +34,6 @@ import csv import logging import os from math import floor from pathlib import Path import numpy as np Loading Loading @@ -117,10 +116,6 @@ def generate_ism_items( # get the number of frames (multiple of 20ms) N_frames = int(len(x.audio) / x.fs * 50) # trim the source signal to align to 20ms boundary # N_trim = int(N_frames * x.fs / 50) # x.audio = x.audio[:N_trim] # adjust the level of the source file _, scale_factor = get_loudness(x, cfg.loudness, "MONO") x.audio *= scale_factor Loading
ivas_processing_scripts/generation/process_stereo_items.py +4 −11 Original line number Diff line number Diff line Loading @@ -30,14 +30,10 @@ # the United Nations Convention on Contracts on the International Sales of Goods. # import csv import logging import os from copy import copy from math import floor from pathlib import Path import numpy as np from math import floor from ivas_processing_scripts.audiotools import audio, audiofile from ivas_processing_scripts.audiotools.wrappers.bs1770 import get_loudness Loading Loading @@ -118,9 +114,6 @@ def generate_stereo_items( "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 Loading Loading @@ -200,16 +193,16 @@ def generate_stereo_items( pre = np.zeros((N_pre, y.audio.shape[1])) y.audio = np.concatenate([pre, y.audio]) if postamble != 0.0: if cfg.postamble != 0.0: # ensure that post-mable is a multiple of 20ms N_post = int(floor(postamble * 50) / 50 * y.fs) N_post = int(floor(cfg.postamble * 50) / 50 * y.fs) # append all-zero postamble to all sources post = np.zeros((N_post, y.audio.shape[1])) y.audio = np.concatenate([y.audio, post]) # add random noise if add_low_level_random_noise: if cfg.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( Loading