Update audioset.py
Browse files- audioset.py +20 -5
audioset.py
CHANGED
|
@@ -58,7 +58,7 @@ class AudioSet(datasets.GeneratorBasedBuilder):
|
|
| 58 |
"label": datasets.Sequence(datasets.features.ClassLabel(names=CLASSES)),
|
| 59 |
}
|
| 60 |
),
|
| 61 |
-
name="
|
| 62 |
description="",
|
| 63 |
),
|
| 64 |
AudioSetConfig(
|
|
@@ -70,7 +70,19 @@ class AudioSet(datasets.GeneratorBasedBuilder):
|
|
| 70 |
"label": datasets.Sequence(datasets.features.ClassLabel(names=CLASSES)),
|
| 71 |
}
|
| 72 |
),
|
| 73 |
-
name="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
description="",
|
| 75 |
),
|
| 76 |
]
|
|
@@ -118,10 +130,13 @@ class AudioSet(datasets.GeneratorBasedBuilder):
|
|
| 118 |
extensions = ['.wav']
|
| 119 |
|
| 120 |
if split == 'train':
|
| 121 |
-
if self.config.name == '
|
| 122 |
archive_path = os.path.join(data_dir, 'audios', 'balanced_train_segments')
|
| 123 |
metadata_url = 'https://huggingface.co/datasets/confit/audioset/resolve/main/metadata/audioset-20k.jsonl'
|
| 124 |
-
elif self.config.name == '
|
|
|
|
|
|
|
|
|
|
| 125 |
archive_path = os.path.join(data_dir, 'audios', 'unbalanced_train_segments')
|
| 126 |
metadata_url = 'https://huggingface.co/datasets/confit/audioset/resolve/main/metadata/audioset-2m.jsonl'
|
| 127 |
elif split == 'test':
|
|
@@ -133,7 +148,7 @@ class AudioSet(datasets.GeneratorBasedBuilder):
|
|
| 133 |
# Split the content by lines and parse each line as JSON
|
| 134 |
# Each line is like {"filename":"YN6UbMsh-q1c.wav","label":["Vehicle","Car"]}
|
| 135 |
data_list = [json.loads(line) for line in response.text.splitlines()]
|
| 136 |
-
fileid2labels = {item['filename']:item['
|
| 137 |
else:
|
| 138 |
logger.info(f"Failed to retrieve data: Status code {response.status_code}")
|
| 139 |
|
|
|
|
| 58 |
"label": datasets.Sequence(datasets.features.ClassLabel(names=CLASSES)),
|
| 59 |
}
|
| 60 |
),
|
| 61 |
+
name="20k",
|
| 62 |
description="",
|
| 63 |
),
|
| 64 |
AudioSetConfig(
|
|
|
|
| 70 |
"label": datasets.Sequence(datasets.features.ClassLabel(names=CLASSES)),
|
| 71 |
}
|
| 72 |
),
|
| 73 |
+
name="500k",
|
| 74 |
+
description="",
|
| 75 |
+
),
|
| 76 |
+
AudioSetConfig(
|
| 77 |
+
features=datasets.Features(
|
| 78 |
+
{
|
| 79 |
+
"file": datasets.Value("string"),
|
| 80 |
+
"audio": datasets.Audio(sampling_rate=SAMPLE_RATE),
|
| 81 |
+
"sound": datasets.Sequence(datasets.Value("string")),
|
| 82 |
+
"label": datasets.Sequence(datasets.features.ClassLabel(names=CLASSES)),
|
| 83 |
+
}
|
| 84 |
+
),
|
| 85 |
+
name="2m",
|
| 86 |
description="",
|
| 87 |
),
|
| 88 |
]
|
|
|
|
| 130 |
extensions = ['.wav']
|
| 131 |
|
| 132 |
if split == 'train':
|
| 133 |
+
if self.config.name == '20k':
|
| 134 |
archive_path = os.path.join(data_dir, 'audios', 'balanced_train_segments')
|
| 135 |
metadata_url = 'https://huggingface.co/datasets/confit/audioset/resolve/main/metadata/audioset-20k.jsonl'
|
| 136 |
+
elif self.config.name == '500k':
|
| 137 |
+
archive_path = os.path.join(data_dir, 'audios', 'unbalanced_train_segments')
|
| 138 |
+
metadata_url = 'https://huggingface.co/datasets/confit/audioset/resolve/main/metadata/audioset-500k.jsonl'
|
| 139 |
+
elif self.config.name == '2m':
|
| 140 |
archive_path = os.path.join(data_dir, 'audios', 'unbalanced_train_segments')
|
| 141 |
metadata_url = 'https://huggingface.co/datasets/confit/audioset/resolve/main/metadata/audioset-2m.jsonl'
|
| 142 |
elif split == 'test':
|
|
|
|
| 148 |
# Split the content by lines and parse each line as JSON
|
| 149 |
# Each line is like {"filename":"YN6UbMsh-q1c.wav","label":["Vehicle","Car"]}
|
| 150 |
data_list = [json.loads(line) for line in response.text.splitlines()]
|
| 151 |
+
fileid2labels = {item['filename']:item['labels'] for item in data_list}
|
| 152 |
else:
|
| 153 |
logger.info(f"Failed to retrieve data: Status code {response.status_code}")
|
| 154 |
|