jaebin0123 commited on
Commit
6630b98
·
verified ·
1 Parent(s): 2ac92c2

Add download helper script

Browse files
Files changed (1) hide show
  1. download_bizcall.py +69 -0
download_bizcall.py ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """Download the bizcall two-speaker dataset from the Hugging Face Hub
3
+ and rewrite the NeMo manifest with absolute local paths.
4
+
5
+ Usage:
6
+ python download_bizcall.py [--out /local/dataset/dir]
7
+
8
+ Requires:
9
+ pip install huggingface_hub
10
+ """
11
+ import argparse
12
+ import json
13
+ from pathlib import Path
14
+
15
+ from huggingface_hub import snapshot_download
16
+
17
+ REPO_ID = "jaebin0123/test"
18
+ REPO_TYPE = "dataset"
19
+
20
+
21
+ def main():
22
+ ap = argparse.ArgumentParser()
23
+ ap.add_argument(
24
+ "--out",
25
+ type=Path,
26
+ default=Path.cwd() / "bizcall",
27
+ help="local directory where the dataset will be placed",
28
+ )
29
+ args = ap.parse_args()
30
+
31
+ args.out.mkdir(parents=True, exist_ok=True)
32
+
33
+ # Pull only what we need: audio/, rttm/, and the manifest.
34
+ local_dir = snapshot_download(
35
+ repo_id=REPO_ID,
36
+ repo_type=REPO_TYPE,
37
+ local_dir=str(args.out),
38
+ allow_patterns=["audio/*", "rttm/*", "bizcall_2spk_manifest.jsonl"],
39
+ )
40
+ local_dir = Path(local_dir).resolve()
41
+ print(f"downloaded to: {local_dir}")
42
+
43
+ # Rewrite the manifest with absolute paths so NeMo can use it directly.
44
+ manifest_in = local_dir / "bizcall_2spk_manifest.jsonl"
45
+ manifest_out = local_dir / "bizcall_2spk_manifest.local.jsonl"
46
+
47
+ if not manifest_in.exists():
48
+ print(f"WARNING: manifest not found at {manifest_in}")
49
+ return
50
+
51
+ with open(manifest_in) as fin, open(manifest_out, "w") as fout:
52
+ for line in fin:
53
+ line = line.strip()
54
+ if not line:
55
+ continue
56
+ entry = json.loads(line)
57
+ entry["audio_filepath"] = entry["audio_filepath"].replace(
58
+ "{BASE}", str(local_dir)
59
+ )
60
+ entry["rttm_filepath"] = entry["rttm_filepath"].replace(
61
+ "{BASE}", str(local_dir)
62
+ )
63
+ fout.write(json.dumps(entry, ensure_ascii=False) + "\n")
64
+
65
+ print(f"local manifest written: {manifest_out}")
66
+
67
+
68
+ if __name__ == "__main__":
69
+ main()