Skip to content

Commit 3a8c4f0

Browse files
committed
fix: source RUASD from official dataset
1 parent 00218be commit 3a8c4f0

4 files changed

Lines changed: 67 additions & 6 deletions

File tree

‎src/gasbench/dataset/config.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ class BenchmarkDatasetConfig:
5959

6060
include_paths: Optional[List[str]] = None
6161
exclude_paths: Optional[List[str]] = None
62+
# Filter media entries inside ZIP/TAR archives. Unlike include_paths and
63+
# exclude_paths, these do not affect which remote archive files are listed.
64+
archive_include_paths: Optional[List[str]] = None
65+
archive_exclude_paths: Optional[List[str]] = None
6266

6367
# For parquet datasets: specify column name(s) containing media bytes
6468
# Works for any modality (image, audio, video)
@@ -380,6 +384,8 @@ def _dataset_dict_to_config(d: dict, **overrides) -> BenchmarkDatasetConfig:
380384
"archives_per_dataset": d.get("archives_per_dataset", 5),
381385
"include_paths": d.get("include_paths"),
382386
"exclude_paths": d.get("exclude_paths"),
387+
"archive_include_paths": d.get("archive_include_paths"),
388+
"archive_exclude_paths": d.get("archive_exclude_paths"),
383389
"data_columns": d.get("data_columns"),
384390
"notes": d.get("notes"),
385391
"filter_column": d.get("filter_column"),

‎src/gasbench/dataset/configs/synthetic_audio.yaml‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -785,12 +785,14 @@ datasets:
785785
notes: Malayalam train split, released from v22 bmcore holdouts
786786

787787
- name: ruasd-audio
788-
path: 34data/ruasd-audio
788+
path: lab260/RuASD
789789
modality: audio
790790
media_type: synthetic
791-
source_format: zip
792-
media_per_archive: -1
793-
archives_per_dataset: -1
791+
source_format: tar
792+
media_per_archive: 500
793+
archives_per_dataset: 2
794+
hf_revision: fcbc87c57b54ef4f58e1135e2813f6f000c2b739
795+
archive_include_paths: [fake]
794796
generator_family: mixed-generation
795797
content_category: speech
796-
notes: Released from v22 bmcore holdouts
798+
notes: Synthetic subset of the official RuASD anti-spoofing dataset

‎src/gasbench/dataset/download/extract.py‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,20 @@ def open_entry(m):
317317
if any(get_name(e).lower().endswith(ext) for ext in valid_exts)
318318
and "MACOSX" not in get_name(e)
319319
]
320+
archive_include_paths = getattr(dataset, "archive_include_paths", None)
321+
archive_exclude_paths = getattr(dataset, "archive_exclude_paths", None)
322+
if archive_include_paths:
323+
candidates = [
324+
entry
325+
for entry in candidates
326+
if any(segment in get_name(entry) for segment in archive_include_paths)
327+
]
328+
if archive_exclude_paths:
329+
candidates = [
330+
entry
331+
for entry in candidates
332+
if not any(segment in get_name(entry) for segment in archive_exclude_paths)
333+
]
320334
if not candidates:
321335
logger.warning(f"No matching files found in {source_path}")
322336
return
@@ -754,4 +768,3 @@ def extract_number(filepath):
754768
logger.warning(f"Error processing frame directory {frame_dir}: {e}")
755769
return
756770

757-
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import io
2+
import tarfile
3+
4+
from gasbench.dataset.config import BenchmarkDatasetConfig
5+
from gasbench.dataset.download.extract import yield_media_from_source
6+
7+
8+
def _write_tar(path, members):
9+
with tarfile.open(path, "w") as archive:
10+
for name, payload in members.items():
11+
info = tarfile.TarInfo(name)
12+
info.size = len(payload)
13+
archive.addfile(info, io.BytesIO(payload))
14+
15+
16+
def test_archive_member_filtering_keeps_only_matching_media(tmp_path):
17+
archive_path = tmp_path / "mixed.tar"
18+
_write_tar(
19+
archive_path,
20+
{
21+
"raw/fake/tts/audio/fake.wav": b"synthetic audio",
22+
"raw/real/speech/audio/real.wav": b"captured audio",
23+
"raw/fake/tts/metadata/fake.json": b"{}",
24+
},
25+
)
26+
dataset = BenchmarkDatasetConfig(
27+
name="mixed-audio",
28+
path="example/mixed-audio",
29+
modality="audio",
30+
media_type="synthetic",
31+
source_format="tar",
32+
archive_include_paths=["/fake/"],
33+
)
34+
35+
samples = list(yield_media_from_source(archive_path, dataset, num_items=-1))
36+
37+
assert [sample["member_path"] for sample in samples] == [
38+
"raw/fake/tts/audio/fake.wav"
39+
]
40+
assert samples[0]["audio_bytes"] == b"synthetic audio"

0 commit comments

Comments
 (0)