csukuangfj commited on
Commit
c012242
1 Parent(s): fc17b62

generate apk audio tagging html

Browse files
Files changed (2) hide show
  1. .gitignore +1 -2
  2. generate-audio-tagging.py +104 -0
.gitignore CHANGED
@@ -1,2 +1 @@
1
- apk.html
2
- apk-engine.html
 
1
+ *.html
 
generate-audio-tagging.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ import os
3
+ import re
4
+ from pathlib import Path
5
+ from typing import List
6
+
7
+ BASE_URL = "https://huggingface.co/csukuangfj/sherpa-onnx-apk/resolve/main/"
8
+
9
+ from dataclasses import dataclass
10
+
11
+
12
+ @dataclass
13
+ class APK:
14
+ major: int
15
+ minor: int
16
+ patch: int
17
+ arch: str
18
+ short_name: str
19
+
20
+ def __init__(self, s):
21
+ s = str(s)[len("audio-tagging/") :]
22
+ split = s.split("-")
23
+ self.major, self.minor, self.patch = list(map(int, split[2].split(".")))
24
+ self.arch = split[3]
25
+ self.short_name = split[6]
26
+ if "arm" in s:
27
+ self.arch += "-" + split[4]
28
+ self.short_name = split[7]
29
+
30
+ if "armeabi" in self.arch:
31
+ self.arch = "y" + self.arch
32
+
33
+ if "arm64" in self.arch:
34
+ self.arch = "z" + self.arch
35
+
36
+ if "small" in self.short_name:
37
+ self.short_name = "zzz" + self.short_name
38
+
39
+
40
+ def sort_by_apk(x):
41
+ x = APK(x)
42
+ return (x.major, x.minor, x.patch, x.arch, x.short_name)
43
+
44
+
45
+ def generate_url(files: List[str]) -> List[str]:
46
+ ans = []
47
+ base = BASE_URL
48
+ for f in files:
49
+ ans.append(base + str(f))
50
+ return ans
51
+
52
+
53
+ def get_all_files(d: str, suffix: str) -> List[str]:
54
+ ans = sorted(Path(d).glob(suffix), key=sort_by_apk, reverse=True)
55
+ return list(map(lambda x: BASE_URL + str(x), ans))
56
+
57
+
58
+ def to_file(filename: str, files: List[str]):
59
+ content = r"""
60
+ <h1> APKs for Audio tagging </h1>
61
+ This page lists the <strong>audio tagging</strong> APKs for <a href="http://github.com/k2-fsa/sherpa-onnx">sherpa-onnx</a>,
62
+ one of the deployment frameworks of <a href="https://github.com/k2-fsa">the Next-gen Kaldi project</a>.
63
+ <br/>
64
+ The name of an APK has the following rule:
65
+ <ul>
66
+ <li> sherpa-onnx-{version}-{arch}-audio-tagging-{model}.apk
67
+ </ul>
68
+ where
69
+ <ul>
70
+ <li> version: It specifies the current version, e.g., 1.9.21
71
+ <li> arch: The architecture targeted by this APK, e.g., arm64-v8a, armeabi-v7a, x86_64, x86
72
+ <li> model: The name of the model used in the APK
73
+ </ul>
74
+
75
+ <br/><br/>
76
+
77
+ You can download all supported models from
78
+ <a href="https://github.com/k2-fsa/sherpa-onnx/releases/tag/audio-tagging-models">https://github.com/k2-fsa/sherpa-onnx/releases/tag/audio-tagging-models</a>
79
+
80
+ <br/>
81
+ <br/>
82
+
83
+ Please see
84
+ <a href="https://k2-fsa.github.io/sherpa/onnx/audio-tagging/">https://k2-fsa.github.io/sherpa/onnx/audio-tagging/</a>
85
+ for more information.
86
+
87
+ <br/>
88
+ <br/>
89
+ <div/>
90
+ """
91
+ with open(filename, "w") as f:
92
+ print(content, file=f)
93
+ for x in files:
94
+ name = x.rsplit("/", maxsplit=1)[-1]
95
+ print(f'<a href="{x}" />{name}<br/>', file=f)
96
+
97
+
98
+ def main():
99
+ apk = get_all_files("audio-tagging", suffix="*.apk")
100
+ to_file("./apk-audio-tagging.html", apk)
101
+
102
+
103
+ if __name__ == "__main__":
104
+ main()