csukuangfj commited on
Commit
93cb4db
1 Parent(s): e3dd74b

html for asr-2pass

Browse files
generate-asr-2pass.py ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-arm64-v8a-asr_2pass-en-small_zipformer_whisper_tiny.apk
22
+ # sherpa-onnx-1.9.23-x86-asr_2pass-en-small_zipformer_whisper_tiny.apk
23
+ s = str(s)[len("asr-2pass/") :]
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">First-pass</th>
107
+ <th class="tg-0pky">Second-pass</th>
108
+ </tr>
109
+ </thead>
110
+ <tbody>
111
+ <tr>
112
+ <td class="tg-0pky">sherpa-onnx-x.y.z-arm64-v8a-asr_2pass-zh-small_zipformer_zipformer.apk</td>
113
+ <td class="tg-0lax">It supports only Chinese.</td>
114
+ <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">sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23</td>
115
+ <td class="tg-0pky"><a href="https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/icefall-asr-zipformer-wenetspeech-20230615.tar.bz2">icefall-asr-zipformer-wenetspeech-20230615</a></td>
116
+ </tr>
117
+ <tr>
118
+ <td class="tg-0pky">sherpa-onnx-x.y.z-arm64-v8a-asr_2pass-zh-small_zipformer_paraformer.apk</td>
119
+ <td class="tg-0lax"><span style="font-weight:400;font-style:normal">It supports only Chinese.</span></td>
120
+ <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">sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23</a></td>
121
+ <td class="tg-0pky"><a href="https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-paraformer-zh-2023-03-28.tar.bz2">sherpa-onnx-paraformer-zh-2023-03-28</a></td>
122
+ </tr>
123
+ <tr>
124
+ <td class="tg-0pky">sherpa-onnx-x.y.z-arm64-v8a-asr_2pass-en-small_zipformer_whisper_tiny.apk</td>
125
+ <td class="tg-0lax">It supports only English.</td>
126
+ <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">sherpa-onnx-streaming-zipformer-en-20M-2023-02-17</a></td>
127
+ <td class="tg-0pky"><a href="https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-whisper-tiny.en.tar.bz2">sherpa-onnx-whisper-tiny.en</a></td>
128
+ </tr>
129
+ </tbody>
130
+ </table>
131
+
132
+ <br/>
133
+ <br/>
134
+
135
+ <div/>
136
+ """
137
+ if "-cn" not in filename:
138
+ content += """
139
+ For Chinese users, please <a href="./apk-2pass-cn.html">visit this address</a>,
140
+ which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
141
+ <br/>
142
+ <br/>
143
+ 中国用户, 请访问<a href="./apk-2pass-cn.html">这个地址</a>
144
+ <br/>
145
+ <br/>
146
+ """
147
+
148
+ with open(filename, "w") as f:
149
+ print(content, file=f)
150
+ for x in files:
151
+ name = x.rsplit("/", maxsplit=1)[-1]
152
+ print(f'<a href="{x}" />{name}<br/>', file=f)
153
+
154
+
155
+ def main():
156
+ apk = get_all_files("asr-2pass", suffix="*.apk")
157
+ to_file("./apk-asr-2pass.html", apk)
158
+
159
+ # for Chinese users
160
+ apk2 = []
161
+ for a in apk:
162
+ a = a.replace("huggingface.co", "hf-mirror.com")
163
+ apk2.append(a)
164
+
165
+ to_file("./apk-asr-2pass-cn.html", apk2)
166
+
167
+
168
+ if __name__ == "__main__":
169
+ main()
generate-asr.py CHANGED
@@ -152,7 +152,7 @@ see https://www.tablesgenerator.com/html_tables#
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
  """
 
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
  """
generate-audio-tagging-wearos.py CHANGED
@@ -101,7 +101,7 @@ For APKs running on Android phones, please see
101
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
102
  <br/>
103
  <br/>
104
- 中文用户, 请访问<a href="./apk-wearos-cn.html">这个地址</a>
105
  <br/>
106
  <br/>
107
  """
 
101
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
102
  <br/>
103
  <br/>
104
+ 中国用户, 请访问<a href="./apk-wearos-cn.html">这个地址</a>
105
  <br/>
106
  <br/>
107
  """
generate-audio-tagging.py CHANGED
@@ -101,7 +101,7 @@ For APKs running on Android wathces with WearOS, please see
101
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
102
  <br/>
103
  <br/>
104
- 中文用户, 请访问<a href="./apk-cn.html">这个地址</a>
105
  <br/>
106
  <br/>
107
  """
 
101
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
102
  <br/>
103
  <br/>
104
+ 中国用户, 请访问<a href="./apk-cn.html">这个地址</a>
105
  <br/>
106
  <br/>
107
  """
generate-slid.py CHANGED
@@ -95,7 +95,7 @@ for more information.
95
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
96
  <br/>
97
  <br/>
98
- 中文用户, 请访问<a href="./apk-cn.html">这个地址</a>
99
  <br/>
100
  <br/>
101
  """
 
95
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
96
  <br/>
97
  <br/>
98
+ 中国用户, 请访问<a href="./apk-cn.html">这个地址</a>
99
  <br/>
100
  <br/>
101
  """
generate-speaker-identification.py CHANGED
@@ -105,7 +105,7 @@ You can download all supported models from
105
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
106
  <br/>
107
  <br/>
108
- 中文用户, 请访问<a href="./apk-cn.html">这个地址</a>
109
  <br/>
110
  <br/>
111
  """
 
105
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
106
  <br/>
107
  <br/>
108
+ 中国用户, 请访问<a href="./apk-cn.html">这个地址</a>
109
  <br/>
110
  <br/>
111
  """
generate-tts-engine.py CHANGED
@@ -112,7 +112,7 @@ at
112
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
113
  <br/>
114
  <br/>
115
- 中文用户, 请访问<a href="./apk-engine-cn.html">这个地址</a>
116
  <br/>
117
  <br/>
118
  """
 
112
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
113
  <br/>
114
  <br/>
115
+ 中国用户, 请访问<a href="./apk-engine-cn.html">这个地址</a>
116
  <br/>
117
  <br/>
118
  """
generate-tts.py CHANGED
@@ -112,7 +112,7 @@ at
112
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
113
  <br/>
114
  <br/>
115
- 中文用户, 请访问<a href="./apk-cn.html">这个地址</a>
116
  <br/>
117
  <br/>
118
  """
 
112
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
113
  <br/>
114
  <br/>
115
+ 中国用户, 请访问<a href="./apk-cn.html">这个地址</a>
116
  <br/>
117
  <br/>
118
  """