Skip to content

Commit

Permalink
fix: all transform only target rate for loudness
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioschneider committed Oct 11, 2022
1 parent 2b56332 commit 17b2786
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
args: [
'--per-file-ignores=__init__.py:F401',
'--max-line-length=88',
'--ignore=E203'
'--ignore=E203,W503'
]

# Checks types
Expand Down
9 changes: 5 additions & 4 deletions audio_data_pytorch/transforms/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 17b2786

Please sign in to comment.