From 17b2786c11ef833f1f5d12eb8eafbadba000a743 Mon Sep 17 00:00:00 2001 From: Flavio Schneider Date: Tue, 11 Oct 2022 15:47:18 +0200 Subject: [PATCH] fix: all transform only target rate for loudness --- .pre-commit-config.yaml | 2 +- audio_data_pytorch/transforms/all.py | 9 +++++---- setup.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0b2832c..5ff5833 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: args: [ '--per-file-ignores=__init__.py:F401', '--max-line-length=88', - '--ignore=E203' + '--ignore=E203,W503' ] # Checks types diff --git a/audio_data_pytorch/transforms/all.py b/audio_data_pytorch/transforms/all.py index 30c3c39..bf0e63e 100644 --- a/audio_data_pytorch/transforms/all.py +++ b/audio_data_pytorch/transforms/all.py @@ -26,15 +26,16 @@ def __init__( ): super().__init__() - message = "Both source_rate and target_rate must be provided" - assert not exists(source_rate) ^ exists(target_rate), message - message = "Loudness requires target_rate" assert not exists(loudness) or exists(target_rate), message self.transform = nn.Sequential( Resample(source=source_rate, target=target_rate) # type: ignore - if exists(source_rate) and source_rate != target_rate + if ( + exists(source_rate) + and exists(target_rate) + and source_rate != target_rate + ) else nn.Identity(), RandomCrop(random_crop_size) if exists(random_crop_size) else nn.Identity(), Crop(crop_size) if exists(crop_size) else nn.Identity(), diff --git a/setup.py b/setup.py index 16f25fb..23df311 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name="audio-data-pytorch", packages=find_packages(exclude=[]), - version="0.0.13", + version="0.0.14", license="MIT", description="Audio Data - PyTorch", long_description_content_type="text/markdown",