csukuangfj commited on
Commit
1f36202
1 Parent(s): bc74dcd

add missing file

Browse files
Files changed (1) hide show
  1. generate-speaker-identification.py +114 -0
generate-speaker-identification.py ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ lang: str
19
+ src: str # piper, coqui
20
+
21
+ def __init__(self, s):
22
+ s = str(s)[len('speaker-identification/'):]
23
+ split = s.split("-")
24
+ self.major, self.minor, self.patch = list(map(int, split[2].split(".")))
25
+ self.arch = split[3]
26
+ self.lang = split[4]
27
+ self.src = split[7]
28
+ if "arm" in s:
29
+ self.arch += "-" + split[4]
30
+ self.lang = split[5]
31
+ self.src = split[8]
32
+
33
+ if "armeabi" in self.arch:
34
+ self.arch = "y" + self.arch
35
+
36
+ if "arm64" in self.arch:
37
+ self.arch = "z" + self.arch
38
+
39
+
40
+ def sort_by_apk(x):
41
+ x = APK(x)
42
+ return (x.major, x.minor, x.patch, x.arch, -ord(x.src[0]), -ord(x.lang[0]))
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 Speaker Identification </h1>
61
+ This page lists the <strong>speaker identification</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}-{lang}-speaker-identification-{framework}-{model}.apk
67
+ </ul>
68
+ where
69
+ <ul>
70
+ <li> version: It specifies the current version, e.g., 1.9.7
71
+ <li> arch: The architecture targeted by this APK, e.g., arm64-v8a, armeabi-v7a, x86_64, x86
72
+ <li> lang: The language supported by this APK, e.g., en for English, zh for Chinese
73
+ <li> framework: The framework where the model is from
74
+ <li> model: The name of the model used in the APK
75
+ </ul>
76
+
77
+ <br/><br/>
78
+
79
+ <span style="color:red;">Note:</span> Models from
80
+ <a href="https://github.com/NVIDIA/NeMo">NVidia/NeMo</a> have their names prefixed
81
+ with <strong>nemo-</strong>.
82
+ <br/><br/>
83
+
84
+ <span style="color:red;">Note:</span> Models from
85
+ <a href="https://github.com/wenet-e2e/wespeaker">wespeaker</a> have their names prefixed
86
+ with <strong>wespeaker-</strong>.
87
+ <br/><br/>
88
+
89
+ <span style="color:red;">Note:</span> Models from
90
+ <a href="https://github.com/alibaba-damo-academy/3D-Speaker">3D-Speaker</a> have their names prefixed
91
+ with <strong>3dspeaker-</strong>.
92
+ </a><br/><br/>
93
+
94
+ You can download all supported models from
95
+ <a href="https://github.com/k2-fsa/sherpa-onnx/releases/tag/speaker-recongition-models">https://github.com/k2-fsa/sherpa-onnx/releases/tag/speaker-recongition-models</a>
96
+
97
+ <br/>
98
+ <br/>
99
+ <div/>
100
+ """
101
+ with open(filename, "w") as f:
102
+ print(content, file=f)
103
+ for x in files:
104
+ name = x.rsplit("/", maxsplit=1)[-1]
105
+ print(f'<a href="{x}" />{name}<br/>', file=f)
106
+
107
+
108
+ def main():
109
+ apk = get_all_files("speaker-identification", suffix="*.apk")
110
+ to_file("./apk-speaker-identification.html", apk)
111
+
112
+
113
+ if __name__ == "__main__":
114
+ main()