csukuangfj commited on
Commit
9ebb268
·
1 Parent(s): 56d2d73

android tts

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. generate-asr.py +0 -8
  3. generate-tts.py +193 -0
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ *.html
generate-asr.py CHANGED
@@ -35,14 +35,6 @@ def sort_by_app(x):
35
  return (x.major, x.minor, x.patch, x.os, x.arch, x.lang, x.short_name)
36
 
37
 
38
- def generate_url(files: List[str]) -> List[str]:
39
- ans = []
40
- base = BASE_URL
41
- for f in files:
42
- ans.append(base + str(f))
43
- return ans
44
-
45
-
46
  def get_all_files(d: str, suffix: str) -> List[str]:
47
  ans = sorted(Path(d).glob(suffix), key=sort_by_app, reverse=False)
48
  return list(map(lambda x: BASE_URL + str(x), ans))
 
35
  return (x.major, x.minor, x.patch, x.os, x.arch, x.lang, x.short_name)
36
 
37
 
 
 
 
 
 
 
 
 
38
  def get_all_files(d: str, suffix: str) -> List[str]:
39
  ans = sorted(Path(d).glob(suffix), key=sort_by_app, reverse=False)
40
  return list(map(lambda x: BASE_URL + str(x), ans))
generate-tts.py ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-flutter/resolve/main/"
8
+
9
+ from dataclasses import dataclass
10
+
11
+
12
+ @dataclass
13
+ class APP:
14
+ major: int
15
+ minor: int
16
+ patch: int
17
+ arch: str
18
+ name1: str
19
+ name2: str
20
+
21
+ def __init__(self, _s):
22
+ # android
23
+ # sherpa-onnx-1.10.11-x86_64-zh-tts-vits-zh-hf-fanchen-wnj.apk
24
+ # sherpa-onnx-1.10.11-armeabi-v7a-zh-tts-vits-zh-hf-keqing.apk
25
+ # sherpa-onnx-1.10.11-x86_64-zh-tts-vits-zh-hf-fanchen-ZhiHuiLaoZhe_new.apk
26
+
27
+ # macos
28
+ # sherpa-onnx-1.10.11-osx-arm64-bn-tts-vits-mimic3-bn-multi_low.app.tar.bz2
29
+ # sherpa-onnx-1.10.11-osx-arm64-zh-tts-vits-zh-hf-theresa.app.tar.bz2
30
+
31
+ # Linux
32
+ # sherpa-onnx-1.10.11-linux-x86_64-zh-tts-vits-zh-hf-zenyatta.tar.bz2
33
+
34
+ # Windows
35
+ # sherpa-onnx-1.10.11-win-x64-zh-tts-vits-zh-hf-zenyatta.tar.bz2
36
+
37
+ s = _s.split('/')[-1]
38
+ split = s.split("-")
39
+ self.major, self.minor, self.patch = list(map(int, split[2].split(".")))
40
+ if 'android' in _s:
41
+ self.os = 'android'
42
+ self.arch = split[3]
43
+ self.lang = split[4]
44
+ self.name1 = split[-1]
45
+
46
+ if 'arm' in _s:
47
+ self.arch = split[3] + '-' + split[4]
48
+ self.lang = split[5]
49
+ else:
50
+ self.os = split[3]
51
+ self.arch = split[4]
52
+ self.lang = split[5]
53
+ self.name1 = split[-1]
54
+
55
+
56
+
57
+
58
+ def sort_by_app(x):
59
+ x = APP(x)
60
+ return (x.major, x.minor, x.patch, x.os, x.arch, x.lang, x.name1)
61
+
62
+
63
+ def get_all_files(d: str, suffix: str) -> List[str]:
64
+ ss = []
65
+ for root, d, files in os.walk(d):
66
+ for f in files:
67
+ if f.endswith('.tar.bz2') or f.endswith('.apk'):
68
+ ss.append(os.path.join(root, f))
69
+
70
+ return list(map(lambda x: BASE_URL + x, ss))
71
+
72
+
73
+ def to_file_android(filename: str, files: List[str]):
74
+ content = r"""
75
+ <h1> Flutter Android APKs for text-to-speech </h1>
76
+
77
+ This page lists the <strong>text-to-speech</strong> APKs created with <a href="https://flutter.dev/">Flutter</a>
78
+ for <a href="http://github.com/k2-fsa/sherpa-onnx">sherpa-onnx</a>,
79
+ one of the deployment frameworks of <a href="https://github.com/k2-fsa">the Next-gen Kaldi project</a>.
80
+
81
+ <br/>
82
+ The name of an APK has the following rule:
83
+ <ul>
84
+ <li> sherpa-onnx-{version}-{arch}-{lang}-tts-{model}.apk
85
+ </ul>
86
+ where
87
+ <ul>
88
+ <li> version: It specifies the current version, e.g., 1.10.11
89
+ <li> arch: The architecture targeted by this APK, e.g., arm64-v8a, armeabi-v7a, x86_64, x86
90
+ <li> lang: The language supported by this APK, e.g., en for English, zh for Chinese, fr for French, de for German, es for Spanish
91
+ <li> model: The name of the model used in the APK, e.g., vits-ljs, vits-piper-de_DE-thorsten-low, vits-piper-de_DE-thorsten-medium
92
+ </ul>
93
+
94
+ <br/>
95
+
96
+ <span style="color:red;">Note:</span> For text-to-speech engine APKs, please see
97
+ <a href="https://k2-fsa.github.io/sherpa/onnx/tts/apk-engine.html">https://k2-fsa.github.io/sherpa/onnx/tts/apk-engine.html</a>
98
+ <br/><br/>
99
+
100
+ <span style="color:red;">Note:</span> Models from
101
+ <a href="https://github.com/rhasspy/piper">piper</a> have their names prefixed
102
+ with <strong>vits-piper-</strong>. For instance, for the model
103
+ <strong>vits-piper-en_US-lessac-medium.apk</strong>, its original name
104
+ in <a href="https://github.com/rhasspy/piper">piper</a> is
105
+ <strong>en_US-lessac-medium.apk</strong>, which is available at
106
+ <a href="https://huggingface.co/rhasspy/piper-voices/blob/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx">
107
+ https://huggingface.co/rhasspy/piper-voices/blob/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx
108
+ </a><br/><br/>
109
+
110
+ <span style="color:red;">Note:</span> Models from
111
+ <a href="https://github.com/MycroftAI/mimic3-voices">MycroftAI/mimic3-voices</a> have their names prefixed
112
+ with <strong>mimic3-</strong>.
113
+ <br/><br/>
114
+
115
+ <span style="color:red;">Note:</span> Models from
116
+ <a href="https://github.com/coqui-ai/TTS">coqui-ai/TTS</a> have their names prefixed
117
+ with <strong>coqui-</strong>.
118
+ <br/><br/>
119
+
120
+ You can find many more models that have not been converted to <strong>sherpa-onnx</strong>
121
+ at
122
+ <a href="https://huggingface.co/rhasspy/piper-voices">https://huggingface.co/rhasspy/piper-voices</a>
123
+
124
+
125
+ <br/>
126
+ <br/>
127
+
128
+ <strong>Note about the license</strong> The code of Next-gen Kaldi is using
129
+ <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache-2.0 license</a>. However,
130
+ we support models from different frameworks. Please check the license of your selected model.
131
+
132
+ <br/>
133
+ <br/>
134
+ <div/>
135
+ """
136
+ if "-cn" not in filename:
137
+ print('filename', filename)
138
+ print(filename.split('/')[-1].split('.'))
139
+ cn_filename = filename.split('/')[-1].split('.')[0] + '-cn.html'
140
+ content += f"""
141
+ For Chinese users, please <a href="./{cn_filename}">visit this address</a>,
142
+ which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
143
+ <br/>
144
+ <br/>
145
+ 中国用户, 请访问<a href="./{cn_filename}">这个地址</a>
146
+ <br/>
147
+ <br/>
148
+ """
149
+
150
+ with open(filename, "w") as f:
151
+ print(content, file=f)
152
+ for x in files:
153
+ name = x.rsplit("/", maxsplit=1)[-1]
154
+ print(f'<a href="{x}" />{name}<br/>', file=f)
155
+
156
+ def get_platform(allFiles: List[str], pattern: str):
157
+ ans = []
158
+ for f in allFiles:
159
+ if pattern in f:
160
+ ans.append(f)
161
+ return ans
162
+
163
+ def main():
164
+ app = get_all_files("flutter/tts", suffix="*.tar.bz2")
165
+
166
+ macos = get_platform(app, 'macos')
167
+ macos_x64 = get_platform(macos, 'x86_64')
168
+ macos_arm64 = get_platform(macos, 'arm64')
169
+
170
+
171
+ windows = get_platform(app, 'windows')
172
+ linux = get_platform(app, 'linux')
173
+ android = get_platform(app, 'android')
174
+
175
+
176
+ android = sorted(android, key=sort_by_app, reverse=False)
177
+ to_file_android("./tts-android.html", android)
178
+ to_file_android("./tts-android-cn.html", android)
179
+ return
180
+
181
+
182
+ # for Chinese users
183
+ app2 = []
184
+ for a in app:
185
+ a = a.replace("huggingface.co", "hf-mirror.com")
186
+ a = a.replace("resolve", "blob")
187
+ app2.append(a)
188
+
189
+ to_file("./app-asr-cn.html", app2)
190
+
191
+
192
+ if __name__ == "__main__":
193
+ main()