Skip to content

Commit

Permalink
Fix: AudioCaps prepare check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Labbeti committed Jan 2, 2024
1 parent 6cb5183 commit 70237de
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/aac_datasets/datasets/functional/audiocaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,19 +540,21 @@ def _is_prepared_audiocaps(
captions_fname = links["captions"]["fname"]
captions_fpath = osp.join(_get_audiocaps_root(root, sr), captions_fname)
audio_subset_dpath = _get_audio_subset_dpath(root, subset, sr)
audio_fnames = os.listdir(audio_subset_dpath)
audio_fnames = [
fname for fname in audio_fnames if fname.endswith(f".{audio_format}")
]

msgs = []

if not osp.isdir(audio_subset_dpath):
msgs.append(f"Cannot find directory '{audio_subset_dpath}'.")
else:
audio_fnames = os.listdir(audio_subset_dpath)
audio_fnames = [
fname for fname in audio_fnames if fname.endswith(f".{audio_format}")
]
if len(audio_fnames) == 0:
msgs.append(f"Cannot find any audio file in '{audio_subset_dpath}'.")

if not osp.isfile(captions_fpath):
msgs.append(f"Cannot find file '{captions_fpath}'.")
if len(audio_fnames) == 0:
msgs.append(f"Cannot find any audio file in '{audio_subset_dpath}'.")

if verbose >= 0:
for msg in msgs:
Expand Down

0 comments on commit 70237de

Please sign in to comment.