Commit 2260c499 authored by Anika Treffehn's avatar Anika Treffehn
Browse files

formatting

parent ca0b490c
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -90,7 +90,9 @@ def reverb(
            tmp_input.fs = IR.fs

        # add trailing zeros
        tmp_input.audio = np.concatenate([tmp_input.audio, np.zeros((IR.audio.shape[0]-1, 1))])
        tmp_input.audio = np.concatenate(
            [tmp_input.audio, np.zeros((IR.audio.shape[0] - 1, 1))]
        )

        # write input audio signal to temporary file in .pcm format
        tmp_input_file = tmp_dir.joinpath("tmp_reverbIn.pcm")
+17 −7
Original line number Diff line number Diff line
@@ -30,11 +30,12 @@
#  the United Nations Convention on Contracts on the International Sales of Goods.
#

from shutil import copyfile
from typing import Optional
from warnings import warn
from shutil import copyfile

from ivas_processing_scripts.audiotools import audio
from ivas_processing_scripts.audiotools.audioarray import trim
from ivas_processing_scripts.audiotools.audiofile import read, write
from ivas_processing_scripts.processing.config import TestConfig
from ivas_processing_scripts.processing.evs import EVS
@@ -45,7 +46,6 @@ from ivas_processing_scripts.processing.preprocessing_2 import Preprocessing2
from ivas_processing_scripts.processing.processing_splitting_scaling import (
    Processing_splitting_scaling,
)
from ivas_processing_scripts.audiotools.audioarray import trim
from ivas_processing_scripts.utils import get_abs_path, list_audio


@@ -569,13 +569,21 @@ def validate_input_files(cfg: TestConfig):

            if n_samples_x % alignment_len_samples != 0:
                if frame_alignment == "warning":
                    warn(f"The length ({n_samples_x} samples) of audio ({item.name}) is not a multiple of the frame length.")
                    warn(
                        f"The length ({n_samples_x} samples) of audio ({item.name}) is not a multiple of the frame length."
                    )
                elif frame_alignment == "error":
                    raise ValueError(f"The length ({n_samples_x} samples) of audio ({item.name}) is not a multiple of the frame length.")
                    raise ValueError(
                        f"The length ({n_samples_x} samples) of audio ({item.name}) is not a multiple of the frame length."
                    )
                elif frame_alignment == "padding":
                    warn(f"The length ({n_samples_x} samples) of audio ({item.name}) is not a multiple of frame length (20 ms). Padding to the nearest integer multiple.")
                    warn(
                        f"The length ({n_samples_x} samples) of audio ({item.name}) is not a multiple of frame length (20 ms). Padding to the nearest integer multiple."
                    )
                    # Calculate number of samples needed for padding
                    padding_samples = int(alignment_len_samples - (n_samples_x % alignment_len_samples))
                    padding_samples = int(
                        alignment_len_samples - (n_samples_x % alignment_len_samples)
                    )
                    # Create and append zeros
                    padded_data = trim(
                        x,
@@ -589,7 +597,9 @@ def validate_input_files(cfg: TestConfig):
                    # Update audio file path in list
                    cfg.items_list[i] = output_dir / item.name
                else:
                    raise ValueError(f"Value of key frame_alignment does not match possible options. Value: {frame_alignment}. Options: 'padding', 'ignore', 'warning', 'error'")
                    raise ValueError(
                        f"Value of key frame_alignment does not match possible options. Value: {frame_alignment}. Options: 'padding', 'ignore', 'warning', 'error'"
                    )
            else:
                if frame_alignment == "padding":
                    copyfile(item, output_dir / item.name)
+2 −6
Original line number Diff line number Diff line
@@ -162,9 +162,7 @@ def concat_setup(cfg: TestConfig, chain, logger: logging.Logger):
    logger.info(f"Splits written to file {splits_info_file}")


def concat_teardown(
    x, splits, out_fmt, fs, in_fs, meta, logger: logging.Logger
):
def concat_teardown(x, splits, out_fmt, fs, in_fs, meta, logger: logging.Logger):
    if not splits:
        raise ValueError("Splitting not possible without split marker")

@@ -434,9 +432,7 @@ def process_item(
                copyfile(ppm, out_meta[idx])


def remove_preamble(
    x, out_fmt, fs, repeat_signal, preamble_len_ms, meta, logger
):
def remove_preamble(x, out_fmt, fs, repeat_signal, preamble_len_ms, meta, logger):
    # remove preamble for ISM metadata
    if out_fmt.startswith("ISM"):