From c3cbb06696db66a1f64cefb096c9acc43d249a42 Mon Sep 17 00:00:00 2001 From: Fawaz Ahmed Date: Mon, 4 Nov 2024 22:58:58 +0530 Subject: [PATCH 1/2] Update audio.py --- src/datasets/features/audio.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/datasets/features/audio.py b/src/datasets/features/audio.py index f7df47b7a06..e384692d06d 100644 --- a/src/datasets/features/audio.py +++ b/src/datasets/features/audio.py @@ -166,8 +166,9 @@ def decode_example( "Decoding 'mp3' files requires system library 'libsndfile'>=1.1.0, " 'You can try to update `soundfile` python library: `pip install "soundfile>=0.12.1"`. ' ) - - if file is None: + if os.path.exists(path): + array, sampling_rate = sf.read(path) + elif file is None: token_per_repo_id = token_per_repo_id or {} source_url = path.split("::")[-1] pattern = ( From efdc2115926d0e6ac79dc503b35a8f9b73644625 Mon Sep 17 00:00:00 2001 From: Fawaz Ahmed Date: Mon, 4 Nov 2024 23:19:05 +0530 Subject: [PATCH 2/2] make sure path is not none --- src/datasets/features/audio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datasets/features/audio.py b/src/datasets/features/audio.py index e384692d06d..9f6bb98ff6c 100644 --- a/src/datasets/features/audio.py +++ b/src/datasets/features/audio.py @@ -166,7 +166,7 @@ def decode_example( "Decoding 'mp3' files requires system library 'libsndfile'>=1.1.0, " 'You can try to update `soundfile` python library: `pip install "soundfile>=0.12.1"`. ' ) - if os.path.exists(path): + if path is not None and os.path.exists(path): array, sampling_rate = sf.read(path) elif file is None: token_per_repo_id = token_per_repo_id or {}