From 2c3f3ac4fa8356ba7ebf5d78a6abc825245d25fd Mon Sep 17 00:00:00 2001 From: AI Date: Fri, 8 Nov 2024 11:10:53 +0200 Subject: [PATCH 1/2] Convert to str for torchaudio.info call --- torch_audiomentations/utils/io.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torch_audiomentations/utils/io.py b/torch_audiomentations/utils/io.py index 9756ee74..25339405 100644 --- a/torch_audiomentations/utils/io.py +++ b/torch_audiomentations/utils/io.py @@ -89,9 +89,9 @@ def rms_normalize(samples: Tensor) -> Tensor: return samples / (rms + 1e-8) @staticmethod - def get_audio_metadata(file_path) -> tuple: + def get_audio_metadata(file_path: str | Path) -> tuple: """Return (num_samples, sample_rate).""" - info = torchaudio.info(file_path) + info = torchaudio.info(str(file_path)) # Deal with backwards-incompatible signature change. # See https://github.com/pytorch/audio/issues/903 for more information. if type(info) is tuple: From 657bf44d04629140a6d90512f8c8d98af33cedfa Mon Sep 17 00:00:00 2001 From: AI Date: Fri, 8 Nov 2024 11:23:54 +0200 Subject: [PATCH 2/2] Backwards-compatible type-hinting --- torch_audiomentations/utils/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torch_audiomentations/utils/io.py b/torch_audiomentations/utils/io.py index 25339405..80b9cdb0 100644 --- a/torch_audiomentations/utils/io.py +++ b/torch_audiomentations/utils/io.py @@ -89,7 +89,7 @@ def rms_normalize(samples: Tensor) -> Tensor: return samples / (rms + 1e-8) @staticmethod - def get_audio_metadata(file_path: str | Path) -> tuple: + def get_audio_metadata(file_path: Union[str, Path]) -> tuple: """Return (num_samples, sample_rate).""" info = torchaudio.info(str(file_path)) # Deal with backwards-incompatible signature change.