csukuangfj commited on
Commit
96b8a02
·
1 Parent(s): 1affb97

add missing files

Browse files
Files changed (5) hide show
  1. .gitignore +1 -0
  2. run.sh +9 -0
  3. update-cpu-html.py +80 -0
  4. update-cuda-html.py +75 -0
  5. util.py +18 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ __pycache__
run.sh ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+
3
+ if [ -d $HOME/open-source/kaldifeat ]; then
4
+ export KALDIFEAT_DIR=$HOME/open-source/kaldifeat
5
+ fi
6
+
7
+ ./update-cuda-html.py
8
+ ./update-cpu-html.py
9
+
update-cpu-html.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ import os
3
+ import re
4
+ from pathlib import Path
5
+
6
+ from util import generate_url, get_all_files
7
+
8
+
9
+ def get_doc_dir():
10
+ kaldifeat_dir = os.getenv("KALDIFEAT_DIR")
11
+ if kaldifeat_dir is None:
12
+ raise ValueError("Please set the environment variable KALDIFEAT_DIR")
13
+
14
+ return Path(kaldifeat_dir) / "doc"
15
+
16
+
17
+ class Wheel:
18
+ def __init__(self, full_name: str, url: str):
19
+ """
20
+ Args:
21
+ full_name:
22
+ Example: kaldifeat-1.24.dev20230722%2Bcuda10.2.torch1.10.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
23
+ """
24
+ self.full_name = full_name
25
+ # pattern = r"kaldifeat-(\d)\.(\d+)(\.(\d+))?\.dev(\d{8})+cpu\.torch(\d\.\d+)"
26
+ pattern = r"kaldifeat-(\d)\.(\d)+((\.)(\d))?\.dev(\d{8})\+cpu\.torch(\d\.\d+\.\d)-cp(\d+)"
27
+ m = re.search(pattern, full_name)
28
+
29
+ self.kaldifeat_major = int(m.group(1))
30
+ self.kaldifeat_minor = int(m.group(2))
31
+ self.kaldifeat_patch = int(m.group(5)) if m.group(5) else 0
32
+ self.kaldifeat_date = int(m.group(6))
33
+ self.torch_version = m.group(7)
34
+ self.py_version = int(m.group(8))
35
+ self.url = url
36
+
37
+ def __str__(self):
38
+ return self.url
39
+
40
+ def __repr__(self):
41
+ return self.url
42
+
43
+
44
+ def sort_by_wheel(x: Wheel):
45
+ torch_major, torch_minor, torch_patch = x.torch_version.split(".")
46
+ torch_major = int(torch_major)
47
+ torch_minor = int(torch_minor)
48
+ torch_patch = int(torch_patch)
49
+ return (
50
+ x.kaldifeat_major,
51
+ x.kaldifeat_minor,
52
+ x.kaldifeat_patch,
53
+ x.kaldifeat_date,
54
+ torch_major,
55
+ torch_minor,
56
+ torch_patch,
57
+ x.py_version,
58
+ )
59
+
60
+
61
+ def main():
62
+ wheels = get_all_files("macos", suffix="*.whl")
63
+ wheels += get_all_files("ubuntu-cpu", suffix="*.whl")
64
+ wheels += get_all_files("windows-cpu", suffix="*.whl")
65
+ urls = generate_url(wheels)
66
+
67
+ wheels = []
68
+ for url in urls:
69
+ full_name = url.rsplit("/", maxsplit=1)[1]
70
+ wheels.append(Wheel(full_name, url))
71
+
72
+ wheels.sort(reverse=True, key=sort_by_wheel)
73
+ d = get_doc_dir()
74
+ with open(d / "source/cpu.html", "w") as f:
75
+ for w in wheels:
76
+ f.write(f'<a href="{w.url}">{w.full_name}</a><br/>\n')
77
+
78
+
79
+ if __name__ == "__main__":
80
+ main()
update-cuda-html.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ import os
3
+ import re
4
+ from pathlib import Path
5
+
6
+ from util import generate_url, get_all_files
7
+
8
+
9
+ def get_doc_dir():
10
+ kaldifeat_dir = os.getenv("KALDIFEAT_DIR")
11
+ if kaldifeat_dir is None:
12
+ raise ValueError("Please set the environment variable KALDIFEAT_DIR")
13
+
14
+ return Path(kaldifeat_dir) / "doc"
15
+
16
+
17
+ class Wheel:
18
+ def __init__(self, full_name: str, url: str):
19
+ """
20
+ Args:
21
+ full_name:
22
+ Example: kaldifeat-1.23.4.dev20230224+cuda10.1.torch1.6.0-cp36-cp36m-linux_x86_64.whl
23
+ """
24
+ self.full_name = full_name
25
+ pattern = r"kaldifeat-(\d)\.(\d)+((\.)(\d))?\.dev(\d{8})\+cuda(\d+)\.(\d+)\.torch(\d\.\d+\.\d)-cp(\d+)"
26
+ m = re.search(pattern, full_name)
27
+
28
+ self.kaldifeat_major = int(m.group(1))
29
+ self.kaldifeat_minor = int(m.group(2))
30
+ self.kaldifeat_patch = int(m.group(5)) if m.group(5) else 0
31
+ self.kaldifeat_date = int(m.group(6))
32
+ self.cuda_major_version = int(m.group(7))
33
+ self.cuda_minor_version = int(m.group(8))
34
+ self.torch_version = m.group(9)
35
+ self.py_version = int(m.group(10))
36
+ self.url = url
37
+
38
+
39
+ def sort_by_wheel(x: Wheel):
40
+ torch_major, torch_minor, torch_patch = x.torch_version.split(".")
41
+ torch_major = int(torch_major)
42
+ torch_minor = int(torch_minor)
43
+ torch_patch = int(torch_patch)
44
+ return (
45
+ x.kaldifeat_major,
46
+ x.kaldifeat_minor,
47
+ x.kaldifeat_patch,
48
+ x.kaldifeat_date,
49
+ torch_major,
50
+ torch_minor,
51
+ torch_patch,
52
+ x.cuda_major_version,
53
+ x.cuda_minor_version,
54
+ x.py_version,
55
+ )
56
+
57
+
58
+ def main():
59
+ wheels = get_all_files("ubuntu-cuda", suffix="*.whl")
60
+ urls = generate_url(wheels)
61
+
62
+ wheels = []
63
+ for url in urls:
64
+ full_name = url.rsplit("/", maxsplit=1)[1]
65
+ wheels.append(Wheel(full_name, url))
66
+
67
+ wheels.sort(reverse=True, key=sort_by_wheel)
68
+ d = get_doc_dir()
69
+ with open(d / "source/cuda.html", "w") as f:
70
+ for w in wheels:
71
+ f.write(f'<a href="{w.url}">{w.full_name}</a><br/>\n')
72
+
73
+
74
+ if __name__ == "__main__":
75
+ main()
util.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+
3
+ from typing import List
4
+ from pathlib import Path
5
+
6
+ BASE_URL = "https://huggingface.co/csukuangfj/kaldifeat/resolve/main/"
7
+
8
+
9
+ def generate_url(files: List[str]) -> List[str]:
10
+ ans = []
11
+ base = BASE_URL
12
+ for f in files:
13
+ ans.append(base + str(f))
14
+ return ans
15
+
16
+
17
+ def get_all_files(d: str, suffix: str) -> List[str]:
18
+ return sorted(Path(d).glob(suffix), reverse=True)