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