Seosnaps commited on
Commit
89f971e
1 Parent(s): d298481

Create count_n_shards.py

Browse files
Files changed (1) hide show
  1. count_n_shards.py +21 -0
count_n_shards.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import path
2
+ import json
3
+
4
+ splits = ["train", "dev", "test", "other", "invalidated"]
5
+
6
+ if __name__ == "__main__":
7
+ n_files = {}
8
+ lang_dirs = [d for d in Path("audio").iterdir() if d.is_dir()]
9
+ for lang_dir in lang_dirs:
10
+ lang = lang_dir.name
11
+ n_files[lang] = {}
12
+ for split in splits:
13
+ split_dir = lang_dir / split
14
+ if split_dir.exists():
15
+ n_files_per_split = len(list(split_dir.glob("*.tar")))
16
+ else:
17
+ n_files_per_split = 0
18
+ n_files[lang][split] = n_files_per_split
19
+
20
+ with open("n_shards.json", "w") as f:
21
+ json.dump(dict(sorted(n_files.items(), key=lambda x: x[0])), f, ensure_ascii=False, indent=4)