csukuangfj commited on
Commit
4eceb20
·
1 Parent(s): 6d90ff0

sort in reverse order

Browse files
Files changed (2) hide show
  1. generate-asr.py +1 -1
  2. generate-tts.py +38 -36
generate-asr.py CHANGED
@@ -36,7 +36,7 @@ def sort_by_app(x):
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))
41
 
42
 
 
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=True)
40
  return list(map(lambda x: BASE_URL + str(x), ans))
41
 
42
 
generate-tts.py CHANGED
@@ -34,17 +34,17 @@ class APP:
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]
@@ -53,8 +53,6 @@ class APP:
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)
@@ -64,7 +62,7 @@ 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))
@@ -134,9 +132,9 @@ we support models from different frameworks. Please check the license of your se
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>
@@ -155,6 +153,7 @@ we support models from different frameworks. Please check the license of your se
155
  name = x.rsplit("/", maxsplit=1)[-1]
156
  print(f'<a href="{x}" />{name}<br/>', file=f)
157
 
 
158
  def to_file_linux(filename: str, files: List[str]):
159
  content = r"""
160
  <h1> Flutter Linux APPs for text-to-speech </h1>
@@ -219,9 +218,9 @@ we support models from different frameworks. Please check the license of your se
219
  <div/>
220
  """
221
  if "-cn" not in filename:
222
- print('filename', filename)
223
- print(filename.split('/')[-1].split('.'))
224
- cn_filename = filename.split('/')[-1].split('.')[0] + '-cn.html'
225
  content += f"""
226
  For Chinese users, please <a href="./{cn_filename}">visit this address</a>,
227
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
@@ -240,6 +239,7 @@ we support models from different frameworks. Please check the license of your se
240
  name = x.rsplit("/", maxsplit=1)[-1]
241
  print(f'<a href="{x}" />{name}<br/>', file=f)
242
 
 
243
  def to_file_macos_x64(filename: str, files: List[str]):
244
  content = r"""
245
  <h1> Flutter macoOS x86_64 APPs for text-to-speech </h1>
@@ -304,9 +304,9 @@ we support models from different frameworks. Please check the license of your se
304
  <div/>
305
  """
306
  if "-cn" not in filename:
307
- print('filename', filename)
308
- print(filename.split('/')[-1].split('.'))
309
- cn_filename = filename.split('/')[-1].split('.')[0] + '-cn.html'
310
  content += f"""
311
  For Chinese users, please <a href="./{cn_filename}">visit this address</a>,
312
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
@@ -325,6 +325,7 @@ we support models from different frameworks. Please check the license of your se
325
  name = x.rsplit("/", maxsplit=1)[-1]
326
  print(f'<a href="{x}" />{name}<br/>', file=f)
327
 
 
328
  def to_file_macos_arm64(filename: str, files: List[str]):
329
  content = r"""
330
  <h1> Flutter macoOS arm64 APPs for text-to-speech </h1>
@@ -389,9 +390,9 @@ we support models from different frameworks. Please check the license of your se
389
  <div/>
390
  """
391
  if "-cn" not in filename:
392
- print('filename', filename)
393
- print(filename.split('/')[-1].split('.'))
394
- cn_filename = filename.split('/')[-1].split('.')[0] + '-cn.html'
395
  content += f"""
396
  For Chinese users, please <a href="./{cn_filename}">visit this address</a>,
397
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
@@ -410,6 +411,7 @@ we support models from different frameworks. Please check the license of your se
410
  name = x.rsplit("/", maxsplit=1)[-1]
411
  print(f'<a href="{x}" />{name}<br/>', file=f)
412
 
 
413
  def to_file_windows(filename: str, files: List[str]):
414
  content = r"""
415
  <h1> Flutter Windows APPs for text-to-speech </h1>
@@ -474,9 +476,9 @@ we support models from different frameworks. Please check the license of your se
474
  <div/>
475
  """
476
  if "-cn" not in filename:
477
- print('filename', filename)
478
- print(filename.split('/')[-1].split('.'))
479
- cn_filename = filename.split('/')[-1].split('.')[0] + '-cn.html'
480
  content += f"""
481
  For Chinese users, please <a href="./{cn_filename}">visit this address</a>,
482
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
@@ -495,6 +497,7 @@ we support models from different frameworks. Please check the license of your se
495
  name = x.rsplit("/", maxsplit=1)[-1]
496
  print(f'<a href="{x}" />{name}<br/>', file=f)
497
 
 
498
  def get_platform(allFiles: List[str], pattern: str):
499
  ans = []
500
  for f in allFiles:
@@ -502,36 +505,35 @@ def get_platform(allFiles: List[str], pattern: str):
502
  ans.append(f)
503
  return ans
504
 
 
505
  def main():
506
  app = get_all_files("flutter/tts", suffix="*.tar.bz2")
507
 
508
- macos = get_platform(app, 'macos')
509
- macos_x64 = get_platform(macos, 'x86_64')
510
- macos_arm64 = get_platform(macos, 'arm64')
511
-
512
-
513
- windows = get_platform(app, 'windows')
514
- linux = get_platform(app, 'linux')
515
- android = get_platform(app, 'android')
516
 
 
 
 
517
 
518
- android = sorted(android, key=sort_by_app, reverse=False)
519
  to_file_android("./tts-android.html", android)
520
  to_file_android("./tts-android-cn.html", android)
521
 
522
- linux = sorted(linux, key=sort_by_app, reverse=False)
523
  to_file_linux("./tts-linux.html", linux)
524
  to_file_linux("./tts-linux-cn.html", linux)
525
 
526
- macos_x64 = sorted(macos_x64, key=sort_by_app, reverse=False)
527
  to_file_macos_x64("./tts-macos-x64.html", macos_x64)
528
  to_file_macos_x64("./tts-macos-x64-cn.html", macos_x64)
529
 
530
- macos_arm64 = sorted(macos_arm64, key=sort_by_app, reverse=False)
531
  to_file_macos_arm64("./tts-macos-arm64.html", macos_arm64)
532
  to_file_macos_arm64("./tts-macos-arm64-cn.html", macos_arm64)
533
 
534
- windows = sorted(windows, key=sort_by_app, reverse=False)
535
  to_file_windows("./tts-win.html", windows)
536
  to_file_windows("./tts-win-cn.html", windows)
537
 
 
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]
 
53
  self.name1 = split[-1]
54
 
55
 
 
 
56
  def sort_by_app(x):
57
  x = APP(x)
58
  return (x.major, x.minor, x.patch, x.os, x.arch, x.lang, x.name1)
 
62
  ss = []
63
  for root, d, files in os.walk(d):
64
  for f in files:
65
+ if f.endswith(".tar.bz2") or f.endswith(".apk"):
66
  ss.append(os.path.join(root, f))
67
 
68
  return list(map(lambda x: BASE_URL + x, ss))
 
132
  <div/>
133
  """
134
  if "-cn" not in filename:
135
+ print("filename", filename)
136
+ print(filename.split("/")[-1].split("."))
137
+ cn_filename = filename.split("/")[-1].split(".")[0] + "-cn.html"
138
  content += f"""
139
  For Chinese users, please <a href="./{cn_filename}">visit this address</a>,
140
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
 
153
  name = x.rsplit("/", maxsplit=1)[-1]
154
  print(f'<a href="{x}" />{name}<br/>', file=f)
155
 
156
+
157
  def to_file_linux(filename: str, files: List[str]):
158
  content = r"""
159
  <h1> Flutter Linux APPs for text-to-speech </h1>
 
218
  <div/>
219
  """
220
  if "-cn" not in filename:
221
+ print("filename", filename)
222
+ print(filename.split("/")[-1].split("."))
223
+ cn_filename = filename.split("/")[-1].split(".")[0] + "-cn.html"
224
  content += f"""
225
  For Chinese users, please <a href="./{cn_filename}">visit this address</a>,
226
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
 
239
  name = x.rsplit("/", maxsplit=1)[-1]
240
  print(f'<a href="{x}" />{name}<br/>', file=f)
241
 
242
+
243
  def to_file_macos_x64(filename: str, files: List[str]):
244
  content = r"""
245
  <h1> Flutter macoOS x86_64 APPs for text-to-speech </h1>
 
304
  <div/>
305
  """
306
  if "-cn" not in filename:
307
+ print("filename", filename)
308
+ print(filename.split("/")[-1].split("."))
309
+ cn_filename = filename.split("/")[-1].split(".")[0] + "-cn.html"
310
  content += f"""
311
  For Chinese users, please <a href="./{cn_filename}">visit this address</a>,
312
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
 
325
  name = x.rsplit("/", maxsplit=1)[-1]
326
  print(f'<a href="{x}" />{name}<br/>', file=f)
327
 
328
+
329
  def to_file_macos_arm64(filename: str, files: List[str]):
330
  content = r"""
331
  <h1> Flutter macoOS arm64 APPs for text-to-speech </h1>
 
390
  <div/>
391
  """
392
  if "-cn" not in filename:
393
+ print("filename", filename)
394
+ print(filename.split("/")[-1].split("."))
395
+ cn_filename = filename.split("/")[-1].split(".")[0] + "-cn.html"
396
  content += f"""
397
  For Chinese users, please <a href="./{cn_filename}">visit this address</a>,
398
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
 
411
  name = x.rsplit("/", maxsplit=1)[-1]
412
  print(f'<a href="{x}" />{name}<br/>', file=f)
413
 
414
+
415
  def to_file_windows(filename: str, files: List[str]):
416
  content = r"""
417
  <h1> Flutter Windows APPs for text-to-speech </h1>
 
476
  <div/>
477
  """
478
  if "-cn" not in filename:
479
+ print("filename", filename)
480
+ print(filename.split("/")[-1].split("."))
481
+ cn_filename = filename.split("/")[-1].split(".")[0] + "-cn.html"
482
  content += f"""
483
  For Chinese users, please <a href="./{cn_filename}">visit this address</a>,
484
  which replaces <a href="huggingface.co">huggingface.co</a> with <a href="hf-mirror.com">hf-mirror.com</a>
 
497
  name = x.rsplit("/", maxsplit=1)[-1]
498
  print(f'<a href="{x}" />{name}<br/>', file=f)
499
 
500
+
501
  def get_platform(allFiles: List[str], pattern: str):
502
  ans = []
503
  for f in allFiles:
 
505
  ans.append(f)
506
  return ans
507
 
508
+
509
  def main():
510
  app = get_all_files("flutter/tts", suffix="*.tar.bz2")
511
 
512
+ macos = get_platform(app, "macos")
513
+ macos_x64 = get_platform(macos, "x86_64")
514
+ macos_arm64 = get_platform(macos, "arm64")
 
 
 
 
 
515
 
516
+ windows = get_platform(app, "windows")
517
+ linux = get_platform(app, "linux")
518
+ android = get_platform(app, "android")
519
 
520
+ android = sorted(android, key=sort_by_app, reverse=True)
521
  to_file_android("./tts-android.html", android)
522
  to_file_android("./tts-android-cn.html", android)
523
 
524
+ linux = sorted(linux, key=sort_by_app, reverse=True)
525
  to_file_linux("./tts-linux.html", linux)
526
  to_file_linux("./tts-linux-cn.html", linux)
527
 
528
+ macos_x64 = sorted(macos_x64, key=sort_by_app, reverse=True)
529
  to_file_macos_x64("./tts-macos-x64.html", macos_x64)
530
  to_file_macos_x64("./tts-macos-x64-cn.html", macos_x64)
531
 
532
+ macos_arm64 = sorted(macos_arm64, key=sort_by_app, reverse=True)
533
  to_file_macos_arm64("./tts-macos-arm64.html", macos_arm64)
534
  to_file_macos_arm64("./tts-macos-arm64-cn.html", macos_arm64)
535
 
536
+ windows = sorted(windows, key=sort_by_app, reverse=True)
537
  to_file_windows("./tts-win.html", windows)
538
  to_file_windows("./tts-win-cn.html", windows)
539