csukuangfj commited on
Commit
e34a616
1 Parent(s): db35f26

html for tts engine apk

Browse files
Files changed (3) hide show
  1. .gitignore +1 -0
  2. generate-tts-engine.py +117 -0
  3. generate-tts.py +19 -10
.gitignore CHANGED
@@ -1 +1,2 @@
1
  apk.html
 
 
1
  apk.html
2
+ apk-engine.html
generate-tts-engine.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)
23
+ split = s.split("-")[1:]
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 text-to-speech engine </h1>
61
+ This page lists the <strong>text-to-speech</strong> engine 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}-tts-engine-{model}.apk
67
+ </ul>
68
+ where
69
+ <ul>
70
+ <li> version: It specifies the current version, e.g., 1.8.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, fr for French, de for German, es for Spanish
73
+ <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
74
+ </ul>
75
+
76
+ <span style="color:red;">Note:</span> For standalone text-to-speech APKs, please see
77
+ <a href="https://k2-fsa.github.io/sherpa/onnx/tts/apk.html">https://k2-fsa.github.io/sherpa/onnx/tts/apk.html</a>
78
+ <br/><br/>
79
+
80
+ <span style="color:red;">Note:</span> Models from
81
+ <a href="https://github.com/rhasspy/piper">piper</a> have their names prefixed
82
+ with <strong>vits-piper-</strong>. For instance, for the model
83
+ <strong>vits-piper-en_US-lessac-medium.apk</strong>, its original name
84
+ in <a href="https://github.com/rhasspy/piper">piper</a> is
85
+ <strong>en_US-lessac-medium.apk</strong>, which is available at
86
+ <a href="https://huggingface.co/rhasspy/piper-voices/blob/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx">
87
+ https://huggingface.co/rhasspy/piper-voices/blob/main/en/en_US/lessac/medium/en_US-lessac-medium.onnx
88
+ </a><br/><br/>
89
+
90
+ <span style="color:red;">Note:</span> Models from
91
+ <a href="https://github.com/coqui-ai/TTS">coqui-ai/TTS</a> have their names prefixed
92
+ with <strong>coqui-</strong>.
93
+ <br/><br/>
94
+
95
+ You can find many more models that have not been converted to <strong>sherpa-onnx</strong>
96
+ at
97
+ <a href="https://huggingface.co/rhasspy/piper-voices">https://huggingface.co/rhasspy/piper-voices</a>
98
+
99
+
100
+ <br/>
101
+ <br/>
102
+ <div/>
103
+ """
104
+ with open(filename, "w") as f:
105
+ print(content, file=f)
106
+ for x in files:
107
+ name = x.rsplit("/", maxsplit=1)[-1]
108
+ print(f'<a href="{x}" />{name}<br/>', file=f)
109
+
110
+
111
+ def main():
112
+ apk = get_all_files("tts-engine", suffix="*.apk")
113
+ to_file("./apk-engine.html", apk)
114
+
115
+
116
+ if __name__ == "__main__":
117
+ main()
generate-tts.py CHANGED
@@ -7,6 +7,8 @@ from typing import List
7
  BASE_URL = "https://huggingface.co/csukuangfj/sherpa-onnx-apk/resolve/main/"
8
 
9
  from dataclasses import dataclass
 
 
10
  @dataclass
11
  class APK:
12
  major: int
@@ -14,28 +16,31 @@ class APK:
14
  patch: int
15
  arch: str
16
  lang: str
17
- src: str # piper, coqui
 
18
  def __init__(self, s):
19
  s = str(s)
20
- split = s.split('-')
21
- self.major, self.minor, self.patch = list(map(int, split[2].split('.')))
22
  self.arch = split[3]
23
  self.lang = split[4]
24
  self.src = split[7]
25
- if 'arm' in s:
26
- self.arch += '-' + split[4]
27
  self.lang = split[5]
28
  self.src = split[8]
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
  def sort_by_apk(x):
37
  x = APK(x)
38
- return (x.major, x.minor, x.patch, x.arch, -ord(x.src[0]),-ord(x.lang[0]))
 
39
 
40
  def generate_url(files: List[str]) -> List[str]:
41
  ans = []
@@ -68,6 +73,10 @@ where
68
  <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
69
  </ul>
70
 
 
 
 
 
71
  <span style="color:red;">Note:</span> Models from
72
  <a href="https://github.com/rhasspy/piper">piper</a> have their names prefixed
73
  with <strong>vits-piper-</strong>. For instance, for the model
 
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
 
16
  patch: int
17
  arch: str
18
  lang: str
19
+ src: str # piper, coqui
20
+
21
  def __init__(self, s):
22
  s = str(s)
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 = []
 
73
  <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
74
  </ul>
75
 
76
+ <span style="color:red;">Note:</span> For text-to-speech engine APKs, please see
77
+ <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>
78
+ <br/><br/>
79
+
80
  <span style="color:red;">Note:</span> Models from
81
  <a href="https://github.com/rhasspy/piper">piper</a> have their names prefixed
82
  with <strong>vits-piper-</strong>. For instance, for the model