Loading ivas_processing_scripts/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ def main(args): cfg.metadata_path = metadata # checking if audio is a multiple of frame size multiple_of_frame_size(cfg.items_list, cfg.input["fmt"]) multiple_of_frame_size(cfg) # run preprocessing only once if hasattr(cfg, "preprocessing"): Loading ivas_processing_scripts/processing/processing.py +25 −9 Original line number Diff line number Diff line Loading @@ -505,25 +505,41 @@ def preprocess_background_noise(cfg): def multiple_of_frame_size( items_list: list, input_format: str, cfg: TestConfig, frame_size_in_ms: Optional[int] = 20, ) -> np.ndarray: """ Warn and pad audio if it isn't a multiple of frame size Warn/Exit if audio if it isn't a multiple of frame size Parameters ---------- items_list: list List of input items cfg: TestConfig Input configuration frame_size_in_ms: Optional[int] Frame size in milliseconds; default = 20 """ for item in items_list: # read file x, fs = read(item) # warning if audio length not a multiple of frame lenght # get the number of channels from the input format input_format = cfg.input["fmt"] num_channels = audio.fromtype(input_format).num_channels for item in cfg.items_list: # read the audio file if "fs" in cfg.input: sampling_rate = cfg.input["fs"] elif item.suffix == ".wav": sampling_rate = None elif item.suffix == ".pcm" or item.suffix == ".raw": raise ValueError("Sampling rate must be specified for headerless files!") x, fs = read(item, nchannels=num_channels, fs=sampling_rate) n_samples_x, n_chan_x = x.shape if fs != sampling_rate: raise ValueError( f"Sampling rate of the file ({fs}) does NOT match with that ({sampling_rate}) specified in the config yaml." ) if n_chan_x != num_channels: raise ValueError( f"The number of channels in the file ({n_chan_x}) do NOT match with those of format ({num_channels}, {input_format}) specified in the config yaml." ) # warn if audio length not a multiple of frame length frame_length_samples = (frame_size_in_ms / 1000) * fs if n_samples_x % frame_length_samples != 0: if input_format.startswith("ISM") or input_format.startswith("MASA"): Loading Loading
ivas_processing_scripts/__init__.py +1 −1 Original line number Diff line number Diff line Loading @@ -128,7 +128,7 @@ def main(args): cfg.metadata_path = metadata # checking if audio is a multiple of frame size multiple_of_frame_size(cfg.items_list, cfg.input["fmt"]) multiple_of_frame_size(cfg) # run preprocessing only once if hasattr(cfg, "preprocessing"): Loading
ivas_processing_scripts/processing/processing.py +25 −9 Original line number Diff line number Diff line Loading @@ -505,25 +505,41 @@ def preprocess_background_noise(cfg): def multiple_of_frame_size( items_list: list, input_format: str, cfg: TestConfig, frame_size_in_ms: Optional[int] = 20, ) -> np.ndarray: """ Warn and pad audio if it isn't a multiple of frame size Warn/Exit if audio if it isn't a multiple of frame size Parameters ---------- items_list: list List of input items cfg: TestConfig Input configuration frame_size_in_ms: Optional[int] Frame size in milliseconds; default = 20 """ for item in items_list: # read file x, fs = read(item) # warning if audio length not a multiple of frame lenght # get the number of channels from the input format input_format = cfg.input["fmt"] num_channels = audio.fromtype(input_format).num_channels for item in cfg.items_list: # read the audio file if "fs" in cfg.input: sampling_rate = cfg.input["fs"] elif item.suffix == ".wav": sampling_rate = None elif item.suffix == ".pcm" or item.suffix == ".raw": raise ValueError("Sampling rate must be specified for headerless files!") x, fs = read(item, nchannels=num_channels, fs=sampling_rate) n_samples_x, n_chan_x = x.shape if fs != sampling_rate: raise ValueError( f"Sampling rate of the file ({fs}) does NOT match with that ({sampling_rate}) specified in the config yaml." ) if n_chan_x != num_channels: raise ValueError( f"The number of channels in the file ({n_chan_x}) do NOT match with those of format ({num_channels}, {input_format}) specified in the config yaml." ) # warn if audio length not a multiple of frame length frame_length_samples = (frame_size_in_ms / 1000) * fs if n_samples_x % frame_length_samples != 0: if input_format.startswith("ISM") or input_format.startswith("MASA"): Loading