File size: 27,159 Bytes
7e9eac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16988a0
7e9eac8
16988a0
7e9eac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ebb01fc
7e9eac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ebb01fc
7e9eac8
 
0969649
7e9eac8
 
 
 
 
 
 
40de727
4cd7d34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40de727
588b97f
f7215c7
0ea07f8
684c796
c5bf357
9462bda
c5bf357
 
9462bda
 
 
 
 
4cd7d34
684c796
0ea07f8
 
4cd7d34
 
bd7955f
4cd7d34
 
 
 
 
 
 
 
 
 
 
 
 
dd6a80b
0ea07f8
4cd7d34
 
 
 
 
 
 
 
 
 
 
 
7e9eac8
684c796
 
 
 
 
7e9eac8
ebb01fc
7e9eac8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ef8e4f3
 
 
 
 
 
 
 
 
 
 
 
 
23e7dca
ef8e4f3
23e7dca
 
 
7e9eac8
 
 
 
 
 
ebb01fc
7e9eac8
 
0969649
7e9eac8
23e7dca
ef8e4f3
 
7e9eac8
 
 
 
 
 
d5f48a5
51a3cc9
407c586
51a3cc9
 
 
d5f48a5
16988a0
 
 
 
 
 
d5f48a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ef8e4f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ddd8e79
 
 
 
 
16988a0
c3cbf61
 
 
 
 
 
16988a0
ef8e4f3
d5f48a5
 
 
 
 
 
16988a0
d5f48a5
 
 
 
 
 
ef8e4f3
 
d5f48a5
 
 
 
 
 
7e9eac8
ebb01fc
7e9eac8
ebb01fc
0c75795
 
7e9eac8
ebb01fc
3344c9b
 
9c1cd2f
 
4826b58
 
20b641c
 
 
 
267004a
 
f18e30d
 
7fcf32c
 
9e48595
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1ae3349
 
 
 
 
 
 
 
 
 
 
a759369
1ae3349
 
 
 
c145060
 
684c796
 
9249790
 
4730e63
 
79cd679
 
117f3c7
 
af3a548
 
34a51df
 
7e9eac8
 
 
 
073ea05
407c586
 
 
7e9eac8
4fb6891
 
 
 
7e9eac8
51a3cc9
ead5f56
bddfec7
73ba5d9
cbfcc94
51a3cc9
4fb6891
51a3cc9
 
0d7f17e
83bc222
7e9eac8
 
 
178d4c6
c5bf357
 
 
 
4930465
8ab4193
f7215c7
 
dcb3ca8
f7215c7
 
 
 
 
dcb3ca8
ca87d1e
f7215c7
 
dcb3ca8
 
ca87d1e
 
 
f7215c7
 
4930465
 
 
ca87d1e
 
 
4930465
 
 
 
 
265ffd4
 
 
7e9eac8
 
3344c9b
1ae3349
f7215c7
 
 
ca87d1e
f7215c7
 
 
 
 
dcb3ca8
3344c9b
 
9c1cd2f
ca87d1e
115a2f7
9c1cd2f
71288ec
34a51df
 
d5f48a5
71288ec
ca87d1e
af3a548
9c1cd2f
7e9eac8
4826b58
1ae3349
34a7ff6
 
ca87d1e
d5f48a5
 
4826b58
ae43e39
 
 
4826b58
 
20b641c
 
0d21a7d
1caf33f
20b641c
 
 
 
 
 
 
 
 
267004a
 
 
 
 
f18e30d
 
 
 
 
 
7fcf32c
 
 
1ae3349
7fcf32c
 
9e48595
70eba44
9e48595
 
 
 
 
34a51df
9e48595
 
 
1ae3349
9e48595
 
af3a548
9e48595
 
 
a759369
9e48595
 
 
34a51df
9e48595
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34a51df
9e48595
 
 
1ae3349
9e48595
 
 
 
ca87d1e
9e48595
 
 
 
 
 
 
 
 
1ae3349
9e48595
 
 
4688f37
34a51df
9e48595
 
 
1ae3349
9e48595
 
 
 
 
 
1ae3349
9e48595
 
 
 
 
1ae3349
9e48595
 
 
 
 
 
 
 
1ae3349
9e48595
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34a51df
9e48595
 
1ae3349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b669d13
1ae3349
 
 
af3a548
c145060
d2e8a11
c573ca8
1ae3349
 
684c796
 
 
 
9249790
 
 
 
4730e63
b669d13
1e2bd9b
117f3c7
4730e63
7394fa7
79cd679
 
 
 
c573ca8
117f3c7
 
 
 
af3a548
 
 
 
34a51df
 
 
 
9e48595
7e9eac8
 
407c586
 
684c796
267004a
117f3c7
c145060
70eba44
f18e30d
1ae3349
7fcf32c
9e48595
 
1ae3349
9e48595
267004a
9e48595
40de727
9e48595
af3a548
9e48595
 
1ae3349
9e48595
 
79cd679
1ae3349
 
9e48595
1ae3349
9e48595
 
4730e63
9e48595
 
 
267004a
9e48595
 
1ae3349
9c1cd2f
9e48595
 
9249790
34a51df
9e48595
20b641c
9e48595
7e9eac8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# Copyright      2022-2023  Xiaomi Corp.        (authors: Fangjun Kuang)
#
# See LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
from functools import lru_cache
from pathlib import Path

import sherpa_onnx
from huggingface_hub import hf_hub_download


def get_file(
    repo_id: str,
    filename: str,
    subfolder: str = ".",
) -> str:
    model_filename = hf_hub_download(
        repo_id=repo_id,
        filename=filename,
        subfolder=subfolder,
    )
    return model_filename


@lru_cache(maxsize=10)
def _get_vits_vctk(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
    assert repo_id == "csukuangfj/vits-vctk"

    model = get_file(
        repo_id=repo_id,
        filename="vits-vctk.onnx",
        subfolder=".",
    )

    lexicon = get_file(
        repo_id=repo_id,
        filename="lexicon.txt",
        subfolder=".",
    )

    tokens = get_file(
        repo_id=repo_id,
        filename="tokens.txt",
        subfolder=".",
    )

    tts_config = sherpa_onnx.OfflineTtsConfig(
        model=sherpa_onnx.OfflineTtsModelConfig(
            vits=sherpa_onnx.OfflineTtsVitsModelConfig(
                model=model,
                lexicon=lexicon,
                tokens=tokens,
                length_scale=1.0 / speed,
            ),
            provider="cpu",
            debug=True,
            num_threads=2,
        )
    )
    tts = sherpa_onnx.OfflineTts(tts_config)

    return tts


@lru_cache(maxsize=10)
def _get_vits_ljs(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
    assert repo_id == "csukuangfj/vits-ljs"

    model = get_file(
        repo_id=repo_id,
        filename="vits-ljs.onnx",
        subfolder=".",
    )

    lexicon = get_file(
        repo_id=repo_id,
        filename="lexicon.txt",
        subfolder=".",
    )

    tokens = get_file(
        repo_id=repo_id,
        filename="tokens.txt",
        subfolder=".",
    )

    tts_config = sherpa_onnx.OfflineTtsConfig(
        model=sherpa_onnx.OfflineTtsModelConfig(
            vits=sherpa_onnx.OfflineTtsVitsModelConfig(
                model=model,
                lexicon=lexicon,
                tokens=tokens,
                length_scale=1.0 / speed,
            ),
            provider="cpu",
            debug=True,
            num_threads=2,
        )
    )
    tts = sherpa_onnx.OfflineTts(tts_config)

    return tts


@lru_cache(maxsize=10)
def _get_vits_piper(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
    data_dir = "/tmp/espeak-ng-data"
    if "coqui" in repo_id or "vits-mms" in repo_id:
        name = "model"
    elif "piper" in repo_id:
        n = len("vits-piper-")
        name = repo_id.split("/")[1][n:]
    elif "mimic3" in repo_id:
        n = len("vits-mimic3-")
        name = repo_id.split("/")[1][n:]
    else:
        raise ValueError(f"Unsupported {repo_id}")

    if "vits-coqui-uk-mai" in repo_id or "vits-mms" in repo_id:
        data_dir = ""

    model = get_file(
        repo_id=repo_id,
        filename=f"{name}.onnx",
        subfolder=".",
    )

    tokens = get_file(
        repo_id=repo_id,
        filename="tokens.txt",
        subfolder=".",
    )

    tts_config = sherpa_onnx.OfflineTtsConfig(
        model=sherpa_onnx.OfflineTtsModelConfig(
            vits=sherpa_onnx.OfflineTtsVitsModelConfig(
                model=model,
                lexicon="",
                data_dir=data_dir,
                tokens=tokens,
                length_scale=1.0 / speed,
            ),
            provider="cpu",
            debug=True,
            num_threads=2,
        )
    )
    tts = sherpa_onnx.OfflineTts(tts_config)

    return tts


@lru_cache(maxsize=10)
def _get_vits_mms(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
    return _get_vits_piper(repo_id, speed)


@lru_cache(maxsize=10)
def _get_vits_zh_aishell3(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
    assert repo_id == "csukuangfj/vits-zh-aishell3"

    model = get_file(
        repo_id=repo_id,
        filename="vits-aishell3.onnx",
        subfolder=".",
    )

    lexicon = get_file(
        repo_id=repo_id,
        filename="lexicon.txt",
        subfolder=".",
    )

    tokens = get_file(
        repo_id=repo_id,
        filename="tokens.txt",
        subfolder=".",
    )

    rule_fsts = ["phone.fst", "date.fst", "number.fst", "new_heteronym.fst"]

    rule_fsts = [
        get_file(
            repo_id=repo_id,
            filename=f,
            subfolder=".",
        )
        for f in rule_fsts
    ]
    rule_fsts = ",".join(rule_fsts)

    rule_fars = get_file(
        repo_id=repo_id,
        filename="rule.far",
        subfolder=".",
    )

    tts_config = sherpa_onnx.OfflineTtsConfig(
        model=sherpa_onnx.OfflineTtsModelConfig(
            vits=sherpa_onnx.OfflineTtsVitsModelConfig(
                model=model,
                lexicon=lexicon,
                tokens=tokens,
                length_scale=1.0 / speed,
            ),
            provider="cpu",
            debug=True,
            num_threads=2,
        ),
        rule_fsts=rule_fsts,
        rule_fars=rule_fars,
    )
    tts = sherpa_onnx.OfflineTts(tts_config)

    return tts


@lru_cache(maxsize=10)
def _get_vits_hf(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
    if "fanchen" in repo_id or "vits-cantonese-hf-xiaomaiiwn" in repo_id:
        model = repo_id.split("/")[-1]
    else:
        model = repo_id.split("-")[-1]

    if not Path("/tmp/dict").is_dir():
        os.system(
            "cd /tmp; curl -SL -O https://github.com/csukuangfj/cppjieba/releases/download/sherpa-onnx-2024-04-19/dict.tar.bz2; tar xvf dict.tar.bz2"
        )
    os.system("ls -lh /tmp/dict")

    model = get_file(
        repo_id=repo_id,
        filename=f"{model}.onnx",
        subfolder=".",
    )

    lexicon = get_file(
        repo_id=repo_id,
        filename="lexicon.txt",
        subfolder=".",
    )

    tokens = get_file(
        repo_id=repo_id,
        filename="tokens.txt",
        subfolder=".",
    )

    rule_fars = ""

    if "vits-cantonese-hf-xiaomaiiwn" not in repo_id:
        rule_fsts = ["phone.fst", "date.fst", "number.fst", "new_heteronym.fst"]

        rule_fsts = [
            get_file(
                repo_id=repo_id,
                filename=f,
                subfolder=".",
            )
            for f in rule_fsts
        ]
        rule_fsts = ",".join(rule_fsts)

        #  rule_fars = get_file(
        #      repo_id=repo_id,
        #      filename="rule.far",
        #      subfolder=".",
        #  )
        vits_dict_dir = "/tmp/dict"
    else:
        rule_fsts = get_file(
            repo_id=repo_id,
            filename="rule.fst",
            subfolder=".",
        )
        vits_dict_dir = ""

    tts_config = sherpa_onnx.OfflineTtsConfig(
        model=sherpa_onnx.OfflineTtsModelConfig(
            vits=sherpa_onnx.OfflineTtsVitsModelConfig(
                model=model,
                lexicon=lexicon,
                tokens=tokens,
                dict_dir=vits_dict_dir,
                length_scale=1.0 / speed,
            ),
            provider="cpu",
            debug=True,
            num_threads=2,
        ),
        rule_fsts=rule_fsts,
        rule_fars=rule_fars,
    )
    tts = sherpa_onnx.OfflineTts(tts_config)

    return tts


@lru_cache(maxsize=10)
def get_pretrained_model(repo_id: str, speed: float) -> sherpa_onnx.OfflineTts:
    if repo_id in chinese_models:
        return chinese_models[repo_id](repo_id, speed)
    if repo_id in cantonese_models:
        return cantonese_models[repo_id](repo_id, speed)
    elif repo_id in english_models:
        return english_models[repo_id](repo_id, speed)
    elif repo_id in german_models:
        return german_models[repo_id](repo_id, speed)
    elif repo_id in spanish_models:
        return spanish_models[repo_id](repo_id, speed)
    elif repo_id in french_models:
        return french_models[repo_id](repo_id, speed)
    elif repo_id in ukrainian_models:
        return ukrainian_models[repo_id](repo_id, speed)
    elif repo_id in russian_models:
        return russian_models[repo_id](repo_id, speed)
    elif repo_id in arabic_models:
        return arabic_models[repo_id](repo_id, speed)
    elif repo_id in catalan_models:
        return catalan_models[repo_id](repo_id, speed)
    elif repo_id in czech_models:
        return czech_models[repo_id](repo_id, speed)
    elif repo_id in danish_models:
        return danish_models[repo_id](repo_id, speed)
    elif repo_id in greek_models:
        return greek_models[repo_id](repo_id, speed)
    elif repo_id in finnish_models:
        return finnish_models[repo_id](repo_id, speed)
    elif repo_id in hungarian_models:
        return hungarian_models[repo_id](repo_id, speed)
    elif repo_id in icelandic_models:
        return icelandic_models[repo_id](repo_id, speed)
    elif repo_id in italian_models:
        return italian_models[repo_id](repo_id, speed)
    elif repo_id in georgian_models:
        return georgian_models[repo_id](repo_id, speed)
    elif repo_id in kazakh_models:
        return kazakh_models[repo_id](repo_id, speed)
    elif repo_id in luxembourgish_models:
        return luxembourgish_models[repo_id](repo_id, speed)
    elif repo_id in nepali_models:
        return nepali_models[repo_id](repo_id, speed)
    elif repo_id in dutch_models:
        return dutch_models[repo_id](repo_id, speed)
    elif repo_id in norwegian_models:
        return norwegian_models[repo_id](repo_id, speed)
    elif repo_id in polish_models:
        return polish_models[repo_id](repo_id, speed)
    elif repo_id in portuguese_models:
        return portuguese_models[repo_id](repo_id, speed)
    elif repo_id in romanian_models:
        return romanian_models[repo_id](repo_id, speed)
    elif repo_id in slovak_models:
        return slovak_models[repo_id](repo_id, speed)
    elif repo_id in serbian_models:
        return serbian_models[repo_id](repo_id, speed)
    elif repo_id in swedish_models:
        return swedish_models[repo_id](repo_id, speed)
    elif repo_id in swahili_models:
        return swahili_models[repo_id](repo_id, speed)
    elif repo_id in turkish_models:
        return turkish_models[repo_id](repo_id, speed)
    elif repo_id in vietnamese_models:
        return vietnamese_models[repo_id](repo_id, speed)
    elif repo_id in bulgarian_models:
        return bulgarian_models[repo_id](repo_id, speed)
    elif repo_id in estonian_models:
        return estonian_models[repo_id](repo_id, speed)
    elif repo_id in irish_models:
        return irish_models[repo_id](repo_id, speed)
    elif repo_id in croatian_models:
        return croatian_models[repo_id](repo_id, speed)
    elif repo_id in lithuanian_models:
        return lithuanian_models[repo_id](repo_id, speed)
    elif repo_id in latvian_models:
        return latvian_models[repo_id](repo_id, speed)
    elif repo_id in maltese_models:
        return maltese_models[repo_id](repo_id, speed)
    elif repo_id in slovenian_models:
        return slovenian_models[repo_id](repo_id, speed)
    elif repo_id in bengali_models:
        return bengali_models[repo_id](repo_id, speed)
    elif repo_id in min_nan_models:
        return min_nan_models[repo_id](repo_id, speed)
    elif repo_id in thai_models:
        return thai_models[repo_id](repo_id, speed)
    elif repo_id in persian_models:
        return persian_models[repo_id](repo_id, speed)
    elif repo_id in korean_models:
        return korean_models[repo_id](repo_id, speed)
    elif repo_id in afrikaans_models:
        return afrikaans_models[repo_id](repo_id, speed)
    elif repo_id in gujarati_models:
        return gujarati_models[repo_id](repo_id, speed)
    elif repo_id in tswana_models:
        return tswana_models[repo_id](repo_id, speed)
    else:
        raise ValueError(f"Unsupported repo_id: {repo_id}")


cantonese_models = {
    "csukuangfj/vits-cantonese-hf-xiaomaiiwn": _get_vits_hf,
}

chinese_models = {
    "csukuangfj/vits-zh-hf-theresa": _get_vits_hf,
    "csukuangfj/vits-zh-hf-eula": _get_vits_hf,
    "csukuangfj/vits-zh-hf-echo": _get_vits_hf,
    "csukuangfj/vits-zh-hf-bronya": _get_vits_hf,
    "csukuangfj/vits-zh-aishell3": _get_vits_zh_aishell3,
    "csukuangfj/vits-zh-hf-fanchen-wnj": _get_vits_hf,
    "csukuangfj/vits-zh-hf-fanchen-C": _get_vits_hf,
    "csukuangfj/vits-zh-hf-fanchen-ZhiHuiLaoZhe": _get_vits_hf,
    "csukuangfj/vits-zh-hf-fanchen-ZhiHuiLaoZhe_new": _get_vits_hf,
    "csukuangfj/vits-zh-hf-fanchen-unity": _get_vits_hf,
    "csukuangfj/vits-zh-hf-doom": _get_vits_hf,
    "csukuangfj/vits-zh-hf-zenyatta": _get_vits_hf,  # 804
    "csukuangfj/vits-zh-hf-abyssinvoker": _get_vits_hf,
    "csukuangfj/vits-zh-hf-keqing": _get_vits_hf,
    "csukuangfj/vits-piper-zh_CN-huayan-medium": _get_vits_piper,
    #  "csukuangfj/vits-piper-zh_CN-huayan-x_low": _get_vits_piper,
}

english_models = {
    "csukuangfj/vits-piper-en_US-glados": _get_vits_piper,
    # coqui-ai
    "csukuangfj/vits-coqui-en-ljspeech": _get_vits_piper,
    "csukuangfj/vits-coqui-en-ljspeech-neon": _get_vits_piper,
    "csukuangfj/vits-coqui-en-vctk": _get_vits_piper,
    # piper, US
    "csukuangfj/vits-piper-en_GB-sweetbbak-amy": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-amy-low": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-amy-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-arctic-medium": _get_vits_piper,  # 18 speakers
    "csukuangfj/vits-piper-en_US-danny-low": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-hfc_male-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-joe-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-kathleen-low": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-kusal-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-l2arctic-medium": _get_vits_piper,  # 24 speakers
    "csukuangfj/vits-piper-en_US-lessac-high": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-lessac-low": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-lessac-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-libritts-high": _get_vits_piper,  # 904 speakers
    "csukuangfj/vits-piper-en_US-libritts_r-medium": _get_vits_piper,  # 904 speakers
    "csukuangfj/vits-piper-en_US-ljspeech-high": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-ljspeech-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-ryan-high": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-ryan-low": _get_vits_piper,
    "csukuangfj/vits-piper-en_US-ryan-medium": _get_vits_piper,
    # piper, GB
    "csukuangfj/vits-piper-en_GB-alan-low": _get_vits_piper,
    "csukuangfj/vits-piper-en_GB-alan-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_GB-alan-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_GB-cori-high": _get_vits_piper,
    "csukuangfj/vits-piper-en_GB-cori-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_GB-jenny_dioco-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_GB-northern_english_male-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_GB-semaine-medium": _get_vits_piper,
    "csukuangfj/vits-piper-en_GB-southern_english_female-low": _get_vits_piper,
    "csukuangfj/vits-piper-en_GB-vctk-medium": _get_vits_piper,
    #
    "csukuangfj/vits-vctk": _get_vits_vctk,  # 109 speakers
    "csukuangfj/vits-ljs": _get_vits_ljs,
}

german_models = {
    "csukuangfj/vits-coqui-de-css10": _get_vits_piper,
    "csukuangfj/vits-piper-de_DE-eva_k-x_low": _get_vits_piper,
    "csukuangfj/vits-piper-de_DE-karlsson-low": _get_vits_piper,
    "csukuangfj/vits-piper-de_DE-kerstin-low": _get_vits_piper,
    "csukuangfj/vits-piper-de_DE-mls-medium": _get_vits_piper,
    "csukuangfj/vits-piper-de_DE-pavoque-low": _get_vits_piper,
    "csukuangfj/vits-piper-de_DE-ramona-low": _get_vits_piper,
    "csukuangfj/vits-piper-de_DE-thorsten-low": _get_vits_piper,
    "csukuangfj/vits-piper-de_DE-thorsten-medium": _get_vits_piper,
    "csukuangfj/vits-piper-de_DE-thorsten-high": _get_vits_piper,
    "csukuangfj/vits-piper-de_DE-thorsten_emotional-medium": _get_vits_piper,  # 8 speakers
}

spanish_models = {
    #  "csukuangfj/vits-coqui-es-css10": _get_vits_piper,
    "csukuangfj/vits-piper-es-glados-medium": _get_vits_piper,
    "csukuangfj/vits-piper-es_ES-carlfm-x_low": _get_vits_piper,
    "csukuangfj/vits-piper-es_ES-davefx-medium": _get_vits_piper,
    #  "csukuangfj/vits-piper-es_ES-mls_10246-low": _get_vits_piper,
    #  "csukuangfj/vits-piper-es_ES-mls_9972-low": _get_vits_piper,
    "csukuangfj/vits-piper-es_ES-sharvard-medium": _get_vits_piper,  # 2 speakers
    "csukuangfj/vits-piper-es_MX-ald-medium": _get_vits_piper,
    "csukuangfj/vits-piper-es_MX-claude-high": _get_vits_piper,
    "csukuangfj/vits-mimic3-es_ES-m-ailabs_low": _get_vits_piper,
}

french_models = {
    "csukuangfj/vits-coqui-fr-css10": _get_vits_piper,
    #  "csukuangfj/vits-piper-fr_FR-gilles-low": _get_vits_piper,
    #  "csukuangfj/vits-piper-fr_FR-mls_1840-low": _get_vits_piper,
    "csukuangfj/vits-piper-fr_FR-mls-medium": _get_vits_piper,  # 2 speakers, 0-femal, 1-male
    "csukuangfj/vits-piper-fr_FR-upmc-medium": _get_vits_piper,  # 2 speakers, 0-femal, 1-male
    "csukuangfj/vits-piper-fr_FR-siwis-low": _get_vits_piper,  # female
    "csukuangfj/vits-piper-fr_FR-siwis-medium": _get_vits_piper,
    "csukuangfj/vits-piper-fr_FR-tjiho-model1": _get_vits_piper,
    "csukuangfj/vits-piper-fr_FR-tjiho-model2": _get_vits_piper,
    "csukuangfj/vits-piper-fr_FR-tjiho-model3": _get_vits_piper,
}

ukrainian_models = {
    "csukuangfj/vits-piper-uk_UA-lada-x_low": _get_vits_piper,
    "csukuangfj/vits-coqui-uk-mai": _get_vits_piper,
    #  "csukuangfj/vits-piper-uk_UA-ukrainian_tts-medium": _get_vits_piper, # does not work somehow
}

russian_models = {
    "csukuangfj/vits-piper-ru_RU-denis-medium": _get_vits_piper,
    "csukuangfj/vits-piper-ru_RU-dmitri-medium": _get_vits_piper,
    "csukuangfj/vits-piper-ru_RU-irina-medium": _get_vits_piper,
    "csukuangfj/vits-piper-ru_RU-ruslan-medium": _get_vits_piper,
}

arabic_models = {
    "csukuangfj/vits-piper-ar_JO-kareem-low": _get_vits_piper,
    "csukuangfj/vits-piper-ar_JO-kareem-medium": _get_vits_piper,
}

catalan_models = {
    "csukuangfj/vits-piper-ca_ES-upc_ona-x_low": _get_vits_piper,
    "csukuangfj/vits-piper-ca_ES-upc_ona-medium": _get_vits_piper,
    "csukuangfj/vits-piper-ca_ES-upc_pau-x_low": _get_vits_piper,
}

czech_models = {
    "csukuangfj/vits-piper-cs_CZ-jirka-low": _get_vits_piper,
    "csukuangfj/vits-piper-cs_CZ-jirka-medium": _get_vits_piper,
    "csukuangfj/vits-coqui-cs-cv": _get_vits_piper,
}

danish_models = {
    "csukuangfj/vits-coqui-da-cv": _get_vits_piper,
    "csukuangfj/vits-piper-da_DK-talesyntese-medium": _get_vits_piper,
}

greek_models = {
    "csukuangfj/vits-piper-el_GR-rapunzelina-low": _get_vits_piper,
    #  "csukuangfj/vits-mimic3-el_GR-rapunzelina_low": _get_vits_piper,
}

finnish_models = {
    "csukuangfj/vits-coqui-fi-css10": _get_vits_piper,
    "csukuangfj/vits-piper-fi_FI-harri-low": _get_vits_piper,
    "csukuangfj/vits-piper-fi_FI-harri-medium": _get_vits_piper,
    "csukuangfj/vits-mimic3-fi_FI-harri-tapani-ylilammi_low": _get_vits_piper,
}

hungarian_models = {
    #  "csukuangfj/vits-coqui-hu-css10": _get_vits_piper,
    "csukuangfj/vits-piper-hu_HU-anna-medium": _get_vits_piper,
    "csukuangfj/vits-piper-hu_HU-berta-medium": _get_vits_piper,
    "csukuangfj/vits-piper-hu_HU-imre-medium": _get_vits_piper,
    "csukuangfj/vits-mimic3-hu_HU-diana-majlinger_low": _get_vits_piper,
}

icelandic_models = {
    "csukuangfj/vits-piper-is_IS-bui-medium": _get_vits_piper,
    "csukuangfj/vits-piper-is_IS-salka-medium": _get_vits_piper,
    "csukuangfj/vits-piper-is_IS-steinn-medium": _get_vits_piper,
    "csukuangfj/vits-piper-is_IS-ugla-medium": _get_vits_piper,
}

italian_models = {
    "csukuangfj/vits-piper-it_IT-riccardo-x_low": _get_vits_piper,
}

georgian_models = {
    "csukuangfj/vits-piper-ka_GE-natia-medium": _get_vits_piper,
}

kazakh_models = {
    "csukuangfj/vits-piper-kk_KZ-iseke-x_low": _get_vits_piper,
    "csukuangfj/vits-piper-kk_KZ-issai-high": _get_vits_piper,
    "csukuangfj/vits-piper-kk_KZ-raya-x_low": _get_vits_piper,
}

luxembourgish_models = {
    "csukuangfj/vits-piper-lb_LU-marylux-medium": _get_vits_piper,
}

nepali_models = {
    "csukuangfj/vits-piper-ne_NP-google-medium": _get_vits_piper,
    "csukuangfj/vits-piper-ne_NP-google-x_low": _get_vits_piper,
    "csukuangfj/vits-mimic3-ne_NP-ne-google_low": _get_vits_piper,
}

dutch_models = {
    "csukuangfj/vits-coqui-nl-css10": _get_vits_piper,
    "csukuangfj/vits-piper-nl_BE-nathalie-medium": _get_vits_piper,
    "csukuangfj/vits-piper-nl_BE-nathalie-x_low": _get_vits_piper,
    "csukuangfj/vits-piper-nl_BE-rdh-medium": _get_vits_piper,
    "csukuangfj/vits-piper-nl_BE-rdh-x_low": _get_vits_piper,
    "csukuangfj/vits-piper-nl_NL-mls-medium": _get_vits_piper,
    "csukuangfj/vits-piper-nl_NL-mls_5809-low": _get_vits_piper,
    "csukuangfj/vits-piper-nl_NL-mls_7432-low": _get_vits_piper,
}

norwegian_models = {
    "csukuangfj/vits-piper-no_NO-talesyntese-medium": _get_vits_piper,
}

polish_models = {
    "csukuangfj/vits-coqui-pl-mai_female": _get_vits_piper,
    "csukuangfj/vits-piper-pl_PL-darkman-medium": _get_vits_piper,
    "csukuangfj/vits-piper-pl_PL-gosia-medium": _get_vits_piper,
    "csukuangfj/vits-piper-pl_PL-mc_speech-medium": _get_vits_piper,
    #  "csukuangfj/vits-piper-pl_PL-mls_6892-low": _get_vits_piper,
    "csukuangfj/vits-mimic3-pl_PL-m-ailabs_low": _get_vits_piper,
}

portuguese_models = {
    "csukuangfj/vits-coqui-pt-cv": _get_vits_piper,
    "csukuangfj/vits-piper-pt_BR-edresson-low": _get_vits_piper,
    "csukuangfj/vits-piper-pt_BR-faber-medium": _get_vits_piper,
    "csukuangfj/vits-piper-pt_PT-tugao-medium": _get_vits_piper,
}

romanian_models = {
    "csukuangfj/vits-coqui-ro-cv": _get_vits_piper,
    "csukuangfj/vits-piper-ro_RO-mihai-medium": _get_vits_piper,
}


slovak_models = {
    "csukuangfj/vits-coqui-sk-cv": _get_vits_piper,
    "csukuangfj/vits-piper-sk_SK-lili-medium": _get_vits_piper,
}

serbian_models = {
    "csukuangfj/vits-piper-sr_RS-serbski_institut-medium": _get_vits_piper,
}

swedish_models = {
    "csukuangfj/vits-coqui-sv-cv": _get_vits_piper,
    "csukuangfj/vits-piper-sv_SE-nst-medium": _get_vits_piper,
}

swahili_models = {
    "csukuangfj/vits-piper-sw_CD-lanfrica-medium": _get_vits_piper,
}

turkish_models = {
    "csukuangfj/vits-piper-tr_TR-dfki-medium": _get_vits_piper,
    "csukuangfj/vits-piper-tr_TR-fahrettin-medium": _get_vits_piper,
}

vietnamese_models = {
    "csukuangfj/vits-piper-vi_VN-25hours_single-low": _get_vits_piper,
    "csukuangfj/vits-piper-vi_VN-vais1000-medium": _get_vits_piper,
    "csukuangfj/vits-piper-vi_VN-vivos-x_low": _get_vits_piper,
    "csukuangfj/vits-mimic3-vi_VN-vais1000_low": _get_vits_piper,
}

bulgarian_models = {
    "csukuangfj/vits-coqui-bg-cv": _get_vits_piper,
}

estonian_models = {
    "csukuangfj/vits-coqui-et-cv": _get_vits_piper,
}

irish_models = {
    "csukuangfj/vits-coqui-ga-cv": _get_vits_piper,
}

croatian_models = {
    "csukuangfj/vits-coqui-hr-cv": _get_vits_piper,
}

lithuanian_models = {
    "csukuangfj/vits-coqui-lt-cv": _get_vits_piper,
}

latvian_models = {
    "csukuangfj/vits-coqui-lv-cv": _get_vits_piper,
}

maltese_models = {
    "csukuangfj/vits-coqui-mt-cv": _get_vits_piper,
}

slovenian_models = {
    "csukuangfj/vits-piper-sl_SI-artur-medium": _get_vits_piper,
    "csukuangfj/vits-coqui-sl-cv": _get_vits_piper,
}

# Bangla
bengali_models = {
    "csukuangfj/vits-coqui-bn-custom_female": _get_vits_piper,
    "csukuangfj/vits-mimic3-bn-multi_low": _get_vits_piper,
}

min_nan_models = {
    "csukuangfj/vits-mms-nan": _get_vits_mms,
}

thai_models = {
    "csukuangfj/vits-mms-tha": _get_vits_mms,
}

persian_models = {
    "csukuangfj/vits-piper-fa_IR-amir-medium": _get_vits_piper,
    "csukuangfj/vits-piper-fa_IR-gyro-medium": _get_vits_piper,
    "csukuangfj/vits-mimic3-fa-haaniye_low": _get_vits_piper,
}

korean_models = {
    "csukuangfj/vits-mimic3-ko_KO-kss_low": _get_vits_piper,
}


afrikaans_models = {
    "csukuangfj/vits-mimic3-af_ZA-google-nwu_low": _get_vits_piper,
}

gujarati_models = {
    "csukuangfj/vits-mimic3-gu_IN-cmu-indic_low": _get_vits_piper,
}

tswana_models = {
    "csukuangfj/vits-mimic3-tn_ZA-google-nwu_low": _get_vits_piper,
}


language_to_models = {
    "English": list(english_models.keys()),
    "Chinese (Mandarin, 普通话)": list(chinese_models.keys()),
    "Cantonese (粤语)": list(cantonese_models.keys()),
    "Min-nan (闽南话)": list(min_nan_models.keys()),
    "Arabic": list(arabic_models.keys()),
    "Afrikaans": list(afrikaans_models.keys()),
    "Bengali": list(bengali_models.keys()),
    "Bulgarian": list(bulgarian_models.keys()),
    "Catalan": list(catalan_models.keys()),
    "Croatian": list(croatian_models.keys()),
    "Czech": list(czech_models.keys()),
    "Danish": list(danish_models.keys()),
    "Dutch": list(dutch_models.keys()),
    "Estonian": list(estonian_models.keys()),
    "Finnish": list(finnish_models.keys()),
    "French": list(french_models.keys()),
    "Georgian": list(georgian_models.keys()),
    "German": list(german_models.keys()),
    "Greek": list(greek_models.keys()),
    "Gujarati": list(gujarati_models.keys()),
    "Hungarian": list(hungarian_models.keys()),
    "Icelandic": list(icelandic_models.keys()),
    "Irish": list(irish_models.keys()),
    "Italian": list(italian_models.keys()),
    "Kazakh": list(kazakh_models.keys()),
    "Korean": list(korean_models.keys()),
    "Latvian": list(latvian_models.keys()),
    "Lithuanian": list(lithuanian_models.keys()),
    "Luxembourgish": list(luxembourgish_models.keys()),
    "Maltese": list(maltese_models.keys()),
    "Nepali": list(nepali_models.keys()),
    "Norwegian": list(norwegian_models.keys()),
    "Persian": list(persian_models.keys()),
    "Polish": list(polish_models.keys()),
    "Portuguese": list(portuguese_models.keys()),
    "Romanian": list(romanian_models.keys()),
    "Russian": list(russian_models.keys()),
    "Serbian": list(serbian_models.keys()),
    "Slovak": list(slovak_models.keys()),
    "Slovenian": list(slovenian_models.keys()),
    "Spanish": list(spanish_models.keys()),
    "Swahili": list(swahili_models.keys()),
    "Swedish": list(swedish_models.keys()),
    "Thai": list(thai_models.keys()),
    "Tswana": list(tswana_models.keys()),
    "Turkish": list(turkish_models.keys()),
    "Ukrainian": list(ukrainian_models.keys()),
    "Vietnamese": list(vietnamese_models.keys()),
}