Skip to content

Commit

Permalink
Mod: AC do not output 'tags' value when with_tags=False. Path managem…
Browse files Browse the repository at this point in the history
…ent now be used with aac_datasets module.
  • Loading branch information
Labbeti committed Sep 14, 2023
1 parent 9e41042 commit 744380d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/aac_datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
from .datasets.clotho import Clotho
from .datasets.macs import MACS
from .datasets.wavcaps import WavCaps
from .utils.paths import (
get_default_ffmpeg_path,
get_default_root,
get_default_ytdl_path,
set_default_ffmpeg_path,
set_default_root,
set_default_ytdl_path,
)


__author__ = "Etienne Labbé (Labbeti)"
Expand Down
12 changes: 9 additions & 3 deletions src/aac_datasets/datasets/audiocaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from torch import Tensor
from torch.hub import download_url_to_file
from torchaudio.backend.common import AudioMetaData
from typing_extensions import TypedDict
from typing_extensions import TypedDict, NotRequired

from aac_datasets.datasets.base import AACDataset, DatasetCard
from aac_datasets.utils.paths import _get_root, _get_ffmpeg_path, _get_ytdl_path
Expand All @@ -49,7 +49,7 @@ class AudioCapsItem(TypedDict, total=True):
# AudioCaps-specific attributes
audiocaps_ids: List[int]
start_time: int
tags: List[int]
tags: NotRequired[List[int]]
youtube_id: str


Expand Down Expand Up @@ -211,10 +211,16 @@ def __init__(
]
raw_data["index"] = list(range(size))

column_names = list(AudioCapsItem.__required_keys__) + list(
AudioCapsItem.__optional_keys__
)
if not with_tags:
column_names.remove("tags")

super().__init__(
raw_data=raw_data,
transform=transform,
column_names=AudioCapsItem.__required_keys__,
column_names=column_names,
flat_captions=flat_captions,
sr=sr,
verbose=verbose,
Expand Down

0 comments on commit 744380d

Please sign in to comment.