csukuangfj commited on
Commit
cd957b2
·
1 Parent(s): f94e9ff

kokoro 1.1-zh

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. kokoro/v11_zh/__init__.py +0 -0
  2. kokoro/v11_zh/generate_v_11_zh.py +101 -0
  3. kokoro/v11_zh/generate_voices_bin.py +27 -0
  4. kokoro/v11_zh/update.sh +5 -0
  5. kokoro/v11_zh/voices/zf_001.txt +0 -0
  6. kokoro/v11_zh/voices/zf_002.txt +0 -0
  7. kokoro/v11_zh/voices/zf_003.txt +0 -0
  8. kokoro/v11_zh/voices/zf_004.txt +0 -0
  9. kokoro/v11_zh/voices/zf_005.txt +0 -0
  10. kokoro/v11_zh/voices/zf_006.txt +0 -0
  11. kokoro/v11_zh/voices/zf_007.txt +0 -0
  12. kokoro/v11_zh/voices/zf_008.txt +0 -0
  13. kokoro/v11_zh/voices/zf_017.txt +0 -0
  14. kokoro/v11_zh/voices/zf_018.txt +0 -0
  15. kokoro/v11_zh/voices/zf_019.txt +0 -0
  16. kokoro/v11_zh/voices/zf_021.txt +0 -0
  17. kokoro/v11_zh/voices/zf_022.txt +0 -0
  18. kokoro/v11_zh/voices/zf_023.txt +0 -0
  19. kokoro/v11_zh/voices/zf_024.txt +0 -0
  20. kokoro/v11_zh/voices/zf_026.txt +0 -0
  21. kokoro/v11_zh/voices/zf_027.txt +0 -0
  22. kokoro/v11_zh/voices/zf_028.txt +0 -0
  23. kokoro/v11_zh/voices/zf_032.txt +0 -0
  24. kokoro/v11_zh/voices/zf_036.txt +0 -0
  25. kokoro/v11_zh/voices/zf_038.txt +0 -0
  26. kokoro/v11_zh/voices/zf_039.txt +0 -0
  27. kokoro/v11_zh/voices/zf_040.txt +0 -0
  28. kokoro/v11_zh/voices/zf_042.txt +0 -0
  29. kokoro/v11_zh/voices/zf_043.txt +0 -0
  30. kokoro/v11_zh/voices/zf_044.txt +0 -0
  31. kokoro/v11_zh/voices/zf_046.txt +0 -0
  32. kokoro/v11_zh/voices/zf_047.txt +0 -0
  33. kokoro/v11_zh/voices/zf_048.txt +0 -0
  34. kokoro/v11_zh/voices/zf_049.txt +0 -0
  35. kokoro/v11_zh/voices/zf_051.txt +0 -0
  36. kokoro/v11_zh/voices/zf_059.txt +0 -0
  37. kokoro/v11_zh/voices/zf_060.txt +0 -0
  38. kokoro/v11_zh/voices/zf_067.txt +0 -0
  39. kokoro/v11_zh/voices/zf_070.txt +0 -0
  40. kokoro/v11_zh/voices/zf_071.txt +0 -0
  41. kokoro/v11_zh/voices/zf_072.txt +0 -0
  42. kokoro/v11_zh/voices/zf_073.txt +0 -0
  43. kokoro/v11_zh/voices/zf_074.txt +0 -0
  44. kokoro/v11_zh/voices/zf_075.txt +0 -0
  45. kokoro/v11_zh/voices/zf_076.txt +0 -0
  46. kokoro/v11_zh/voices/zf_077.txt +0 -0
  47. kokoro/v11_zh/voices/zf_078.txt +0 -0
  48. kokoro/v11_zh/voices/zf_079.txt +0 -0
  49. kokoro/v11_zh/voices/zf_083.txt +0 -0
  50. kokoro/v11_zh/voices/zf_084.txt +0 -0
kokoro/v11_zh/__init__.py ADDED
File without changes
kokoro/v11_zh/generate_v_11_zh.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .generate_voices_bin import id2speaker
2
+
3
+
4
+ def generate_kokoro_v_11():
5
+ s = f"""
6
+ # kokoro-multi-lang-v1_1
7
+
8
+ ## Info about this model
9
+
10
+ This model is kokoro v1.1-zh and it is from <https://huggingface.co/hexgrad/Kokoro-82M-v1.1-zh>
11
+
12
+ It supports both `Chinese` and `English`.
13
+
14
+ | Number of speakers | Sample rate |
15
+ |--------------------|-------------|
16
+ | {len(id2speaker)} | 24000|
17
+
18
+ ### Meaning of speaker prefix
19
+
20
+ |Prefix|Meaning| sid range| Number of speakers|
21
+ |---|---|---|---|
22
+ |af | American female|0 - 1| 2|
23
+ |bf| British female| 2| 1 |
24
+ |zf| Chinese female| 3 - 57 | 55 |
25
+ |zm| Chinese male| 58 - 102 | 45 |
26
+
27
+ ### speaker ID to speaker name (sid -> name)
28
+ The mapping from speaker ID (sid) to speaker name is given below:
29
+
30
+ """
31
+
32
+ num_per_line = 4
33
+
34
+ t = "|" * (num_per_line + 2)
35
+ t += "\n"
36
+ t += "|---" * (num_per_line + 1)
37
+ t += "|\n"
38
+
39
+ t += f"|0 - {num_per_line-1}"
40
+
41
+ for i, (sid, name) in enumerate(id2speaker.items()):
42
+ t += f"|{sid} -> {name}"
43
+ if (i + 1) % num_per_line == 0:
44
+ t += "|\n"
45
+ if (i + 1) == min(i + num_per_line, len(id2speaker) - 1):
46
+ t += f"|{i+1}"
47
+ else:
48
+ t += f"|{i+1} - {min(i+num_per_line, len(id2speaker)-1)}"
49
+ while (i + 1) % num_per_line != 0:
50
+ t += "|"
51
+ i += 1
52
+ t += "|\n"
53
+
54
+ s += t
55
+
56
+ s += """
57
+ ### speaker name to speaker ID (name -> sid)
58
+ The mapping from speaker name to speaker ID (sid) is given below:
59
+
60
+ """
61
+
62
+ t = "|" * (num_per_line + 2)
63
+ t += "\n"
64
+ t += "|---" * (num_per_line + 1)
65
+ t += "|\n"
66
+
67
+ t += f"|0 - {num_per_line-1}"
68
+
69
+ for i, (sid, name) in enumerate(id2speaker.items()):
70
+ t += f"|{name} -> {sid}"
71
+ if (i + 1) % num_per_line == 0:
72
+ t += "|\n"
73
+ t += f"|{i+1} - {min(i+num_per_line, len(id2speaker)-1)}"
74
+ while (i + 1) % num_per_line != 0:
75
+ t += "|"
76
+ i += 1
77
+ t += "|\n"
78
+
79
+ s += t
80
+
81
+ s += """
82
+ ## Samples
83
+
84
+ For the following text:
85
+
86
+ This model supports both Chinese and English. 小米的核心价值观是什么?答案
87
+ 是真诚热爱!有困难,请拨打110 或者18601200909。I am learning 机器学习.
88
+ 我在研究 machine learning。What do you think 中英文说的如何呢?
89
+ 今天是 2025年6月18号.
90
+
91
+ sample audios for different speakers are listed below:
92
+
93
+ """
94
+ for sid, name in id2speaker.items():
95
+ s += f"\n### Speaker {sid} - {name}\n"
96
+ s += f"""\n<audio controls>
97
+ <source src="/sherpa/onnx/tts/all/kokoro/v1.1-zh/mp3//{sid}-{name}.mp3" type="audio/mp3">
98
+ </audio>\n\n"""
99
+
100
+ with open("book/src/Chinese-English/kokoro-multi-lang-v1_1.md", "w") as f:
101
+ f.write(s)
kokoro/v11_zh/generate_voices_bin.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # Copyright 2025 Xiaomi Corp. (authors: Fangjun Kuang)
3
+ import torch
4
+ from pathlib import Path
5
+
6
+
7
+ speakers = [
8
+ "af_maple",
9
+ "af_sol",
10
+ "bf_vale",
11
+ ]
12
+
13
+ d = Path(__file__).parent
14
+ for i in range(1, 99 + 1):
15
+ name = "zf_{:03d}".format(i)
16
+ if Path(f"{d}/voices/{name}.txt").is_file():
17
+ speakers.append(name)
18
+
19
+ for i in range(9, 100 + 1):
20
+ name = "zm_{:03d}".format(i)
21
+ if Path(f"{d}/voices/{name}.txt").is_file():
22
+ speakers.append(name)
23
+
24
+
25
+ id2speaker = {index: value for index, value in enumerate(speakers)}
26
+
27
+ speaker2id = {speaker: idx for idx, speaker in id2speaker.items()}
kokoro/v11_zh/update.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -ex
3
+
4
+ cp /Users/fangjun/open-source/sherpa-onnx/scripts/kokoro/v1.1-zh/generate_voices_bin.py .
5
+
kokoro/v11_zh/voices/zf_001.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_002.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_003.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_004.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_005.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_006.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_007.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_008.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_017.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_018.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_019.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_021.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_022.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_023.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_024.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_026.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_027.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_028.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_032.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_036.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_038.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_039.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_040.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_042.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_043.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_044.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_046.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_047.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_048.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_049.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_051.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_059.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_060.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_067.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_070.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_071.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_072.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_073.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_074.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_075.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_076.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_077.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_078.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_079.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_083.txt ADDED
File without changes
kokoro/v11_zh/voices/zf_084.txt ADDED
File without changes