csukuangfj commited on
Commit
fdb75f4
1 Parent(s): fe99bc3

add apk for asr

Browse files
Files changed (1) hide show
  1. generate-asr.py +181 -0
generate-asr.py ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # sherpa-onnx-1.9.23-x86_64-asr-en-zipformer2.apk
22
+ # sherpa-onnx-1.9.23-arm64-v8a-asr-zh-zipformer2.apk
23
+ s = str(s)[len("asr/") :]
24
+ split = s.split("-")
25
+ self.major, self.minor, self.patch = list(map(int, split[2].split(".")))
26
+ self.arch = split[3]
27
+ self.lang = split[5]
28
+ self.short_name = split[6]
29
+ if "arm" in s:
30
+ self.arch += "-" + split[4]
31
+ self.lang = split[6]
32
+ self.short_name = split[7]
33
+
34
+ if "armeabi" in self.arch:
35
+ self.arch = "y" + self.arch
36
+
37
+ if "arm64" in self.arch:
38
+ self.arch = "z" + self.arch
39
+
40
+ if "small" in self.short_name:
41
+ self.short_name = "zzz" + self.short_name
42
+
43
+
44
+ def sort_by_apk(x):
45
+ x = APK(x)
46
+ return (x.major, x.minor, x.patch, x.arch, x.lang, x.short_name)
47
+
48
+
49
+ def generate_url(files: List[str]) -> List[str]:
50
+ ans = []
51
+ base = BASE_URL
52
+ for f in files:
53
+ ans.append(base + str(f))
54
+ return ans
55
+
56
+
57
+ def get_all_files(d: str, suffix: str) -> List[str]:
58
+ ans = sorted(Path(d).glob(suffix), key=sort_by_apk, reverse=True)
59
+ return list(map(lambda x: BASE_URL + str(x), ans))
60
+
61
+
62
+ def to_file(filename: str, files: List[str]):
63
+ content = r"""
64
+ <h1> APKs for streaming speech recognition </h1>
65
+ This page lists the <strong>streaming speech recognition</strong> APKs for <a href="http://github.com/k2-fsa/sherpa-onnx">sherpa-onnx</a>,
66
+ one of the deployment frameworks of <a href="https://github.com/k2-fsa">the Next-gen Kaldi project</a>.
67
+ <br/>
68
+ The name of an APK has the following rule:
69
+ <ul>
70
+ <li> sherpa-onnx-{version}-{arch}-asr-{lang}-{model}.apk
71
+ </ul>
72
+ where
73
+ <ul>
74
+ <li> version: It specifies the current version, e.g., 1.9.23
75
+ <li> arch: The architecture targeted by this APK, e.g., arm64-v8a, armeabi-v7a, x86_64, x86
76
+ <li> lang: The lang of the model used in the APK, e.g., en for English, zh for Chinese
77
+ <li> model: The name of the model used in the APK
78
+ </ul>
79
+
80
+ <br/>
81
+
82
+ You can download all supported models from
83
+ <a href="https://github.com/k2-fsa/sherpa-onnx/releases/tag/asr-models">https://github.com/k2-fsa/sherpa-onnx/releases/tag/asr-models</a>
84
+
85
+ <br/>
86
+ <br/>
87
+
88
+ <!--
89
+ see https://www.tablesgenerator.com/html_tables#
90
+ -->
91
+
92
+ <style type="text/css">
93
+ .tg {border-collapse:collapse;border-spacing:0;}
94
+ .tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
95
+ overflow:hidden;padding:10px 5px;word-break:normal;}
96
+ .tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
97
+ font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
98
+ .tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
99
+ .tg .tg-0lax{text-align:left;vertical-align:top}
100
+ </style>
101
+ <table class="tg">
102
+ <thead>
103
+ <tr>
104
+ <th class="tg-0pky">APK</th>
105
+ <th class="tg-0lax">Comment</th>
106
+ <th class="tg-0pky">Model Name</th>
107
+ <th class="tg-0pky">Model Link</th>
108
+ </tr>
109
+ </thead>
110
+ <tbody>
111
+ <tr>
112
+ <td class="tg-0pky">sherpa-onnx-x.y.z-arm64-v8a-asr-bilingual_zh_en-zipformer.apk</td>
113
+ <td class="tg-0lax">It supports both English and Chinese.</td>
114
+ <td class="tg-0pky">sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20</td>
115
+ <td class="tg-0pky"><a href="https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2">https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2</a></td>
116
+ </tr>
117
+ <tr>
118
+ <td class="tg-0pky">sherpa-onnx-x.y.z-arm64-v8a-asr-fr-zipformer.apk</td>
119
+ <td class="tg-0lax"><span style="font-weight:400;font-style:normal">It supports only French.</span></td>
120
+ <td class="tg-0pky">sherpa-onnx-streaming-zipformer-fr-2023-04-14</td>
121
+ <td class="tg-0pky"><a href="https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-fr-2023-04-14.tar.bz2">https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-fr-2023-04-14.tar.bz2</a></td>
122
+ </tr>
123
+ <tr>
124
+ <td class="tg-0pky">sherpa-onnx-x.y.z-arm64-v8a-asr-zh-zipformer2.apk</td>
125
+ <td class="tg-0lax">It supports only Chinese.</td>
126
+ <td class="tg-0pky">icefall-asr-zipformer-streaming-wenetspeech-20230615</td>
127
+ <td class="tg-0pky"><a href="https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/icefall-asr-zipformer-streaming-wenetspeech-20230615.tar.bz2">https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/icefall-asr-zipformer-streaming-wenetspeech-20230615.tar.bz2</a></td>
128
+ </tr>
129
+ <tr>
130
+ <td class="tg-0pky">sherpa-onnx-x.y.z-arm64-v8a-asr-zh-small_zipformer.apk</td>
131
+ <td class="tg-0lax">It supports only Chinese.<br>It uses the smallest zipformer and runs<br>super fast, though its accuracy is not that good.</td>
132
+ <td class="tg-0pky">sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23</td>
133
+ <td class="tg-0pky"><a href="https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2">https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23.tar.bz2</a></td>
134
+ </tr>
135
+ <tr>
136
+ <td class="tg-0pky">sherpa-onnx-x.y.z-arm64-v8a-asr-en-small_zipformer.apk</td>
137
+ <td class="tg-0lax">It suppors only English.<br>It uses a very small zipformer and runs<br>super fast, though its accuracy is not that good.</td>
138
+ <td class="tg-0pky">sherpa-onnx-streaming-zipformer-en-20M-2023-02-17</td>
139
+ <td class="tg-0pky"><a href="https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-en-20M-2023-02-17.tar.bz2">https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-en-20M-2023-02-17.tar.bz2</a></td>
140
+ </tr>
141
+ </tbody>
142
+ </table>
143
+
144
+ <br/>
145
+ <br/>
146
+
147
+ <div/>
148
+ """
149
+ if "-cn" not in filename:
150
+ content += """
151
+ For Chinese users, please <a href="./apk-cn.html">visit this address</a>,
152
+ which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
153
+ <br/>
154
+ <br/>
155
+ 中文用户, 请访问<a href="./apk-cn.html">这个地址</a>
156
+ <br/>
157
+ <br/>
158
+ """
159
+
160
+ with open(filename, "w") as f:
161
+ print(content, file=f)
162
+ for x in files:
163
+ name = x.rsplit("/", maxsplit=1)[-1]
164
+ print(f'<a href="{x}" />{name}<br/>', file=f)
165
+
166
+
167
+ def main():
168
+ apk = get_all_files("asr", suffix="*.apk")
169
+ to_file("./apk-asr.html", apk)
170
+
171
+ # for Chinese users
172
+ apk2 = []
173
+ for a in apk:
174
+ a = a.replace("huggingface.co", "hf-mirror.com")
175
+ apk2.append(a)
176
+
177
+ to_file("./apk-asr-cn.html", apk2)
178
+
179
+
180
+ if __name__ == "__main__":
181
+ main()