Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +43 -35
- README.md +86 -1
- checkpoints/vocab.txt +2545 -0
- config.json +16 -0
- f5_tts/api.py +166 -0
- f5_tts/configs/E2TTS_Base_train.yaml +44 -0
- f5_tts/configs/E2TTS_Small_train.yaml +44 -0
- f5_tts/configs/F5TTS_Base_train.yaml +46 -0
- f5_tts/configs/F5TTS_Small_train.yaml +46 -0
- f5_tts/eval/README.md +49 -0
- f5_tts/eval/ecapa_tdnn.py +330 -0
- f5_tts/eval/eval_infer_batch.py +207 -0
- f5_tts/eval/eval_infer_batch.sh +13 -0
- f5_tts/eval/eval_librispeech_test_clean.py +84 -0
- f5_tts/eval/eval_seedtts_testset.py +84 -0
- f5_tts/eval/utils_eval.py +405 -0
- f5_tts/infer/README.md +193 -0
- f5_tts/infer/SHARED.md +103 -0
- f5_tts/infer/__pycache__/utils_infer.cpython-310.pyc +0 -0
- f5_tts/infer/__pycache__/utils_infer.cpython-312.pyc +0 -0
- f5_tts/infer/examples/basic/basic.toml +11 -0
- f5_tts/infer/examples/basic/basic_ref_en.wav +3 -0
- f5_tts/infer/examples/basic/basic_ref_zh.wav +3 -0
- f5_tts/infer/examples/multi/country.flac +3 -0
- f5_tts/infer/examples/multi/main.flac +3 -0
- f5_tts/infer/examples/multi/story.toml +19 -0
- f5_tts/infer/examples/multi/story.txt +1 -0
- f5_tts/infer/examples/multi/town.flac +3 -0
- f5_tts/infer/examples/vocab.txt +2545 -0
- f5_tts/infer/infer_batch_parallel.py +171 -0
- f5_tts/infer/infer_cli.py +226 -0
- f5_tts/infer/infer_cli_batch.py +245 -0
- f5_tts/infer/infer_gradio.py +855 -0
- f5_tts/infer/infer_gradio_orig.py +853 -0
- f5_tts/infer/speech_edit.py +193 -0
- f5_tts/infer/utils_infer.py +552 -0
- f5_tts/model/__init__.py +10 -0
- f5_tts/model/__pycache__/__init__.cpython-310.pyc +0 -0
- f5_tts/model/__pycache__/cfm.cpython-310.pyc +0 -0
- f5_tts/model/__pycache__/dataset.cpython-310.pyc +0 -0
- f5_tts/model/__pycache__/modules.cpython-310.pyc +0 -0
- f5_tts/model/__pycache__/trainer.cpython-310.pyc +0 -0
- f5_tts/model/__pycache__/utils.cpython-310.pyc +0 -0
- f5_tts/model/backbones/README.md +20 -0
- f5_tts/model/backbones/__pycache__/dit.cpython-310.pyc +0 -0
- f5_tts/model/backbones/__pycache__/mmdit.cpython-310.pyc +0 -0
- f5_tts/model/backbones/__pycache__/unett.cpython-310.pyc +0 -0
- f5_tts/model/backbones/dit.py +163 -0
- f5_tts/model/backbones/mmdit.py +146 -0
- f5_tts/model/backbones/unett.py +219 -0
.gitattributes
CHANGED
@@ -1,35 +1,43 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
f5_tts/infer/examples/basic/basic_ref_en.wav filter=lfs diff=lfs merge=lfs -text
|
37 |
+
f5_tts/infer/examples/basic/basic_ref_zh.wav filter=lfs diff=lfs merge=lfs -text
|
38 |
+
f5_tts/infer/examples/multi/country.flac filter=lfs diff=lfs merge=lfs -text
|
39 |
+
f5_tts/infer/examples/multi/main.flac filter=lfs diff=lfs merge=lfs -text
|
40 |
+
f5_tts/infer/examples/multi/town.flac filter=lfs diff=lfs merge=lfs -text
|
41 |
+
prompts/MAR_F_HAPPY_00001.wav filter=lfs diff=lfs merge=lfs -text
|
42 |
+
prompts/PAN_F_HAPPY_00001.wav filter=lfs diff=lfs merge=lfs -text
|
43 |
+
samples/namaste.wav filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,3 +1,88 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
datasets:
|
3 |
+
- ai4bharat/indicvoices_r
|
4 |
+
- ai4bharat/Rasa
|
5 |
+
language:
|
6 |
+
- as
|
7 |
+
- bn
|
8 |
+
- gu
|
9 |
+
- mr
|
10 |
+
- hi
|
11 |
+
- kn
|
12 |
+
- ml
|
13 |
+
- or
|
14 |
+
- pa
|
15 |
+
- ta
|
16 |
+
- te
|
17 |
+
pipeline_tag: text-to-speech
|
18 |
---
|
19 |
+
# **IndicF5: High-Quality Text-to-Speech for Indian Languages**
|
20 |
+
|
21 |
+
|
22 |
+
We release **IndicF5**, a **near-human polyglot** **Text-to-Speech (TTS)** model trained on **1417 hours** of high-quality speech from **[Rasa](https://huggingface.co/datasets/ai4bharat/Rasa), [IndicTTS](https://www.iitm.ac.in/donlab/indictts/database), [LIMMITS](https://sites.google.com/view/limmits24/), and [IndicVoices-R](https://huggingface.co/datasets/ai4bharat/indicvoices_r)**.
|
23 |
+
|
24 |
+
IndicF5 supports **11 Indian languages**:
|
25 |
+
**Assamese, Bengali, Gujarati, Hindi, Kannada, Malayalam, Marathi, Odia, Punjabi, Tamil, Telugu.**
|
26 |
+
|
27 |
+
---
|
28 |
+
|
29 |
+
## 🚀 Installation
|
30 |
+
```bash
|
31 |
+
conda create -n indicf5 python=3.10 -y
|
32 |
+
conda activate indicf5
|
33 |
+
pip install git+https://github.com/ai4bharat/IndicF5.git
|
34 |
+
```
|
35 |
+
|
36 |
+
|
37 |
+
## 🎙 Usage
|
38 |
+
|
39 |
+
To generate speech, you need to provide **three inputs**:
|
40 |
+
1. **Text to synthesize** – The content you want the model to speak.
|
41 |
+
2. **A reference prompt audio** – An example speech clip that guides the model’s prosody and speaker characteristics.
|
42 |
+
3. **Text spoken in the reference prompt audio** – The transcript of the reference prompt audio.
|
43 |
+
|
44 |
+
|
45 |
+
```python
|
46 |
+
from transformers import AutoModel
|
47 |
+
import numpy as np
|
48 |
+
import soundfile as sf
|
49 |
+
|
50 |
+
# Load IndicF5 from Hugging Face
|
51 |
+
repo_id = "ai4bharat/IndicF5"
|
52 |
+
model = AutoModel.from_pretrained(repo_id, trust_remote_code=True)
|
53 |
+
|
54 |
+
# Generate speech
|
55 |
+
audio = model(
|
56 |
+
"नमस्ते! संगीत की तरह जीवन भी खूबसूरत होता है, बस इसे सही ताल में जीना आना चाहिए.",
|
57 |
+
ref_audio_path="prompts/PAN_F_HAPPY_00001.wav",
|
58 |
+
ref_text="ਭਹੰਪੀ ਵਿੱਚ ਸਮਾਰਕਾਂ ਦੇ ਭਵਨ ਨਿਰਮਾਣ ਕਲਾ ਦੇ ਵੇਰਵੇ ਗੁੰਝਲਦਾਰ ਅਤੇ ਹੈਰਾਨ ਕਰਨ ਵਾਲੇ ਹਨ, ਜੋ ਮੈਨੂੰ ਖੁਸ਼ ਕਰਦੇ ਹਨ।"
|
59 |
+
)
|
60 |
+
|
61 |
+
# Normalize and save output
|
62 |
+
if audio.dtype == np.int16:
|
63 |
+
audio = audio.astype(np.float32) / 32768.0
|
64 |
+
sf.write("namaste.wav", np.array(audio, dtype=np.float32), samplerate=24000)
|
65 |
+
print("Audio saved succesfully.")
|
66 |
+
```
|
67 |
+
|
68 |
+
You can find example prompt audios used [here](https://huggingface.co/ai4bharat/IndicF5/tree/main/prompts).
|
69 |
+
|
70 |
+
## Terms of Use
|
71 |
+
By using this model, you agree to only clone voices for which you have explicit permission. Unauthorized voice cloning is strictly prohibited. Any misuse of this model is the responsibility of the user.
|
72 |
+
|
73 |
+
## References
|
74 |
+
|
75 |
+
We would like to extend our gratitude to the authors of **[F5-TTS](https://github.com/SWivid/F5-TTS)** for their invaluable contributions and inspiration to this work. Their efforts have played a crucial role in advancing the field of text-to-speech synthesis.
|
76 |
+
|
77 |
+
|
78 |
+
## 📖 Citation
|
79 |
+
If you use **IndicF5** in your research or projects, please consider citing it:
|
80 |
+
|
81 |
+
### 🔹 BibTeX
|
82 |
+
```bibtex
|
83 |
+
@misc{AI4Bharat_IndicF5_2025,
|
84 |
+
author = {Praveen S V and Srija Anand and Soma Siddhartha and Mitesh M. Khapra},
|
85 |
+
title = {IndicF5: High-Quality Text-to-Speech for Indian Languages},
|
86 |
+
year = {2025},
|
87 |
+
url = {https://github.com/AI4Bharat/IndicF5},
|
88 |
+
}
|
checkpoints/vocab.txt
ADDED
@@ -0,0 +1,2545 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
41 |
+
I
|
42 |
+
J
|
43 |
+
K
|
44 |
+
L
|
45 |
+
M
|
46 |
+
N
|
47 |
+
O
|
48 |
+
P
|
49 |
+
Q
|
50 |
+
R
|
51 |
+
S
|
52 |
+
T
|
53 |
+
U
|
54 |
+
V
|
55 |
+
W
|
56 |
+
X
|
57 |
+
Y
|
58 |
+
Z
|
59 |
+
[
|
60 |
+
\
|
61 |
+
]
|
62 |
+
_
|
63 |
+
a
|
64 |
+
a1
|
65 |
+
ai1
|
66 |
+
ai2
|
67 |
+
ai3
|
68 |
+
ai4
|
69 |
+
an1
|
70 |
+
an3
|
71 |
+
an4
|
72 |
+
ang1
|
73 |
+
ang2
|
74 |
+
ang4
|
75 |
+
ao1
|
76 |
+
ao2
|
77 |
+
ao3
|
78 |
+
ao4
|
79 |
+
b
|
80 |
+
ba
|
81 |
+
ba1
|
82 |
+
ba2
|
83 |
+
ba3
|
84 |
+
ba4
|
85 |
+
bai1
|
86 |
+
bai2
|
87 |
+
bai3
|
88 |
+
bai4
|
89 |
+
ban1
|
90 |
+
ban2
|
91 |
+
ban3
|
92 |
+
ban4
|
93 |
+
bang1
|
94 |
+
bang2
|
95 |
+
bang3
|
96 |
+
bang4
|
97 |
+
bao1
|
98 |
+
bao2
|
99 |
+
bao3
|
100 |
+
bao4
|
101 |
+
bei
|
102 |
+
bei1
|
103 |
+
bei2
|
104 |
+
bei3
|
105 |
+
bei4
|
106 |
+
ben1
|
107 |
+
ben2
|
108 |
+
ben3
|
109 |
+
ben4
|
110 |
+
beng
|
111 |
+
beng1
|
112 |
+
beng2
|
113 |
+
beng3
|
114 |
+
beng4
|
115 |
+
bi1
|
116 |
+
bi2
|
117 |
+
bi3
|
118 |
+
bi4
|
119 |
+
bian1
|
120 |
+
bian2
|
121 |
+
bian3
|
122 |
+
bian4
|
123 |
+
biao1
|
124 |
+
biao2
|
125 |
+
biao3
|
126 |
+
bie1
|
127 |
+
bie2
|
128 |
+
bie3
|
129 |
+
bie4
|
130 |
+
bin1
|
131 |
+
bin4
|
132 |
+
bing1
|
133 |
+
bing2
|
134 |
+
bing3
|
135 |
+
bing4
|
136 |
+
bo
|
137 |
+
bo1
|
138 |
+
bo2
|
139 |
+
bo3
|
140 |
+
bo4
|
141 |
+
bu2
|
142 |
+
bu3
|
143 |
+
bu4
|
144 |
+
c
|
145 |
+
ca1
|
146 |
+
cai1
|
147 |
+
cai2
|
148 |
+
cai3
|
149 |
+
cai4
|
150 |
+
can1
|
151 |
+
can2
|
152 |
+
can3
|
153 |
+
can4
|
154 |
+
cang1
|
155 |
+
cang2
|
156 |
+
cao1
|
157 |
+
cao2
|
158 |
+
cao3
|
159 |
+
ce4
|
160 |
+
cen1
|
161 |
+
cen2
|
162 |
+
ceng1
|
163 |
+
ceng2
|
164 |
+
ceng4
|
165 |
+
cha1
|
166 |
+
cha2
|
167 |
+
cha3
|
168 |
+
cha4
|
169 |
+
chai1
|
170 |
+
chai2
|
171 |
+
chan1
|
172 |
+
chan2
|
173 |
+
chan3
|
174 |
+
chan4
|
175 |
+
chang1
|
176 |
+
chang2
|
177 |
+
chang3
|
178 |
+
chang4
|
179 |
+
chao1
|
180 |
+
chao2
|
181 |
+
chao3
|
182 |
+
che1
|
183 |
+
che2
|
184 |
+
che3
|
185 |
+
che4
|
186 |
+
chen1
|
187 |
+
chen2
|
188 |
+
chen3
|
189 |
+
chen4
|
190 |
+
cheng1
|
191 |
+
cheng2
|
192 |
+
cheng3
|
193 |
+
cheng4
|
194 |
+
chi1
|
195 |
+
chi2
|
196 |
+
chi3
|
197 |
+
chi4
|
198 |
+
chong1
|
199 |
+
chong2
|
200 |
+
chong3
|
201 |
+
chong4
|
202 |
+
chou1
|
203 |
+
chou2
|
204 |
+
chou3
|
205 |
+
chou4
|
206 |
+
chu1
|
207 |
+
chu2
|
208 |
+
chu3
|
209 |
+
chu4
|
210 |
+
chua1
|
211 |
+
chuai1
|
212 |
+
chuai2
|
213 |
+
chuai3
|
214 |
+
chuai4
|
215 |
+
chuan1
|
216 |
+
chuan2
|
217 |
+
chuan3
|
218 |
+
chuan4
|
219 |
+
chuang1
|
220 |
+
chuang2
|
221 |
+
chuang3
|
222 |
+
chuang4
|
223 |
+
chui1
|
224 |
+
chui2
|
225 |
+
chun1
|
226 |
+
chun2
|
227 |
+
chun3
|
228 |
+
chuo1
|
229 |
+
chuo4
|
230 |
+
ci1
|
231 |
+
ci2
|
232 |
+
ci3
|
233 |
+
ci4
|
234 |
+
cong1
|
235 |
+
cong2
|
236 |
+
cou4
|
237 |
+
cu1
|
238 |
+
cu4
|
239 |
+
cuan1
|
240 |
+
cuan2
|
241 |
+
cuan4
|
242 |
+
cui1
|
243 |
+
cui3
|
244 |
+
cui4
|
245 |
+
cun1
|
246 |
+
cun2
|
247 |
+
cun4
|
248 |
+
cuo1
|
249 |
+
cuo2
|
250 |
+
cuo4
|
251 |
+
d
|
252 |
+
da
|
253 |
+
da1
|
254 |
+
da2
|
255 |
+
da3
|
256 |
+
da4
|
257 |
+
dai1
|
258 |
+
dai2
|
259 |
+
dai3
|
260 |
+
dai4
|
261 |
+
dan1
|
262 |
+
dan2
|
263 |
+
dan3
|
264 |
+
dan4
|
265 |
+
dang1
|
266 |
+
dang2
|
267 |
+
dang3
|
268 |
+
dang4
|
269 |
+
dao1
|
270 |
+
dao2
|
271 |
+
dao3
|
272 |
+
dao4
|
273 |
+
de
|
274 |
+
de1
|
275 |
+
de2
|
276 |
+
dei3
|
277 |
+
den4
|
278 |
+
deng1
|
279 |
+
deng2
|
280 |
+
deng3
|
281 |
+
deng4
|
282 |
+
di1
|
283 |
+
di2
|
284 |
+
di3
|
285 |
+
di4
|
286 |
+
dia3
|
287 |
+
dian1
|
288 |
+
dian2
|
289 |
+
dian3
|
290 |
+
dian4
|
291 |
+
diao1
|
292 |
+
diao3
|
293 |
+
diao4
|
294 |
+
die1
|
295 |
+
die2
|
296 |
+
die4
|
297 |
+
ding1
|
298 |
+
ding2
|
299 |
+
ding3
|
300 |
+
ding4
|
301 |
+
diu1
|
302 |
+
dong1
|
303 |
+
dong3
|
304 |
+
dong4
|
305 |
+
dou1
|
306 |
+
dou2
|
307 |
+
dou3
|
308 |
+
dou4
|
309 |
+
du1
|
310 |
+
du2
|
311 |
+
du3
|
312 |
+
du4
|
313 |
+
duan1
|
314 |
+
duan2
|
315 |
+
duan3
|
316 |
+
duan4
|
317 |
+
dui1
|
318 |
+
dui4
|
319 |
+
dun1
|
320 |
+
dun3
|
321 |
+
dun4
|
322 |
+
duo1
|
323 |
+
duo2
|
324 |
+
duo3
|
325 |
+
duo4
|
326 |
+
e
|
327 |
+
e1
|
328 |
+
e2
|
329 |
+
e3
|
330 |
+
e4
|
331 |
+
ei2
|
332 |
+
en1
|
333 |
+
en4
|
334 |
+
er
|
335 |
+
er2
|
336 |
+
er3
|
337 |
+
er4
|
338 |
+
f
|
339 |
+
fa1
|
340 |
+
fa2
|
341 |
+
fa3
|
342 |
+
fa4
|
343 |
+
fan1
|
344 |
+
fan2
|
345 |
+
fan3
|
346 |
+
fan4
|
347 |
+
fang1
|
348 |
+
fang2
|
349 |
+
fang3
|
350 |
+
fang4
|
351 |
+
fei1
|
352 |
+
fei2
|
353 |
+
fei3
|
354 |
+
fei4
|
355 |
+
fen1
|
356 |
+
fen2
|
357 |
+
fen3
|
358 |
+
fen4
|
359 |
+
feng1
|
360 |
+
feng2
|
361 |
+
feng3
|
362 |
+
feng4
|
363 |
+
fo2
|
364 |
+
fou2
|
365 |
+
fou3
|
366 |
+
fu1
|
367 |
+
fu2
|
368 |
+
fu3
|
369 |
+
fu4
|
370 |
+
g
|
371 |
+
ga1
|
372 |
+
ga2
|
373 |
+
ga3
|
374 |
+
ga4
|
375 |
+
gai1
|
376 |
+
gai2
|
377 |
+
gai3
|
378 |
+
gai4
|
379 |
+
gan1
|
380 |
+
gan2
|
381 |
+
gan3
|
382 |
+
gan4
|
383 |
+
gang1
|
384 |
+
gang2
|
385 |
+
gang3
|
386 |
+
gang4
|
387 |
+
gao1
|
388 |
+
gao2
|
389 |
+
gao3
|
390 |
+
gao4
|
391 |
+
ge1
|
392 |
+
ge2
|
393 |
+
ge3
|
394 |
+
ge4
|
395 |
+
gei2
|
396 |
+
gei3
|
397 |
+
gen1
|
398 |
+
gen2
|
399 |
+
gen3
|
400 |
+
gen4
|
401 |
+
geng1
|
402 |
+
geng3
|
403 |
+
geng4
|
404 |
+
gong1
|
405 |
+
gong3
|
406 |
+
gong4
|
407 |
+
gou1
|
408 |
+
gou2
|
409 |
+
gou3
|
410 |
+
gou4
|
411 |
+
gu
|
412 |
+
gu1
|
413 |
+
gu2
|
414 |
+
gu3
|
415 |
+
gu4
|
416 |
+
gua1
|
417 |
+
gua2
|
418 |
+
gua3
|
419 |
+
gua4
|
420 |
+
guai1
|
421 |
+
guai2
|
422 |
+
guai3
|
423 |
+
guai4
|
424 |
+
guan1
|
425 |
+
guan2
|
426 |
+
guan3
|
427 |
+
guan4
|
428 |
+
guang1
|
429 |
+
guang2
|
430 |
+
guang3
|
431 |
+
guang4
|
432 |
+
gui1
|
433 |
+
gui2
|
434 |
+
gui3
|
435 |
+
gui4
|
436 |
+
gun3
|
437 |
+
gun4
|
438 |
+
guo1
|
439 |
+
guo2
|
440 |
+
guo3
|
441 |
+
guo4
|
442 |
+
h
|
443 |
+
ha1
|
444 |
+
ha2
|
445 |
+
ha3
|
446 |
+
hai1
|
447 |
+
hai2
|
448 |
+
hai3
|
449 |
+
hai4
|
450 |
+
han1
|
451 |
+
han2
|
452 |
+
han3
|
453 |
+
han4
|
454 |
+
hang1
|
455 |
+
hang2
|
456 |
+
hang4
|
457 |
+
hao1
|
458 |
+
hao2
|
459 |
+
hao3
|
460 |
+
hao4
|
461 |
+
he1
|
462 |
+
he2
|
463 |
+
he4
|
464 |
+
hei1
|
465 |
+
hen2
|
466 |
+
hen3
|
467 |
+
hen4
|
468 |
+
heng1
|
469 |
+
heng2
|
470 |
+
heng4
|
471 |
+
hong1
|
472 |
+
hong2
|
473 |
+
hong3
|
474 |
+
hong4
|
475 |
+
hou1
|
476 |
+
hou2
|
477 |
+
hou3
|
478 |
+
hou4
|
479 |
+
hu1
|
480 |
+
hu2
|
481 |
+
hu3
|
482 |
+
hu4
|
483 |
+
hua1
|
484 |
+
hua2
|
485 |
+
hua4
|
486 |
+
huai2
|
487 |
+
huai4
|
488 |
+
huan1
|
489 |
+
huan2
|
490 |
+
huan3
|
491 |
+
huan4
|
492 |
+
huang1
|
493 |
+
huang2
|
494 |
+
huang3
|
495 |
+
huang4
|
496 |
+
hui1
|
497 |
+
hui2
|
498 |
+
hui3
|
499 |
+
hui4
|
500 |
+
hun1
|
501 |
+
hun2
|
502 |
+
hun4
|
503 |
+
huo
|
504 |
+
huo1
|
505 |
+
huo2
|
506 |
+
huo3
|
507 |
+
huo4
|
508 |
+
i
|
509 |
+
j
|
510 |
+
ji1
|
511 |
+
ji2
|
512 |
+
ji3
|
513 |
+
ji4
|
514 |
+
jia
|
515 |
+
jia1
|
516 |
+
jia2
|
517 |
+
jia3
|
518 |
+
jia4
|
519 |
+
jian1
|
520 |
+
jian2
|
521 |
+
jian3
|
522 |
+
jian4
|
523 |
+
jiang1
|
524 |
+
jiang2
|
525 |
+
jiang3
|
526 |
+
jiang4
|
527 |
+
jiao1
|
528 |
+
jiao2
|
529 |
+
jiao3
|
530 |
+
jiao4
|
531 |
+
jie1
|
532 |
+
jie2
|
533 |
+
jie3
|
534 |
+
jie4
|
535 |
+
jin1
|
536 |
+
jin2
|
537 |
+
jin3
|
538 |
+
jin4
|
539 |
+
jing1
|
540 |
+
jing2
|
541 |
+
jing3
|
542 |
+
jing4
|
543 |
+
jiong3
|
544 |
+
jiu1
|
545 |
+
jiu2
|
546 |
+
jiu3
|
547 |
+
jiu4
|
548 |
+
ju1
|
549 |
+
ju2
|
550 |
+
ju3
|
551 |
+
ju4
|
552 |
+
juan1
|
553 |
+
juan2
|
554 |
+
juan3
|
555 |
+
juan4
|
556 |
+
jue1
|
557 |
+
jue2
|
558 |
+
jue4
|
559 |
+
jun1
|
560 |
+
jun4
|
561 |
+
k
|
562 |
+
ka1
|
563 |
+
ka2
|
564 |
+
ka3
|
565 |
+
kai1
|
566 |
+
kai2
|
567 |
+
kai3
|
568 |
+
kai4
|
569 |
+
kan1
|
570 |
+
kan2
|
571 |
+
kan3
|
572 |
+
kan4
|
573 |
+
kang1
|
574 |
+
kang2
|
575 |
+
kang4
|
576 |
+
kao1
|
577 |
+
kao2
|
578 |
+
kao3
|
579 |
+
kao4
|
580 |
+
ke1
|
581 |
+
ke2
|
582 |
+
ke3
|
583 |
+
ke4
|
584 |
+
ken3
|
585 |
+
keng1
|
586 |
+
kong1
|
587 |
+
kong3
|
588 |
+
kong4
|
589 |
+
kou1
|
590 |
+
kou2
|
591 |
+
kou3
|
592 |
+
kou4
|
593 |
+
ku1
|
594 |
+
ku2
|
595 |
+
ku3
|
596 |
+
ku4
|
597 |
+
kua1
|
598 |
+
kua3
|
599 |
+
kua4
|
600 |
+
kuai3
|
601 |
+
kuai4
|
602 |
+
kuan1
|
603 |
+
kuan2
|
604 |
+
kuan3
|
605 |
+
kuang1
|
606 |
+
kuang2
|
607 |
+
kuang4
|
608 |
+
kui1
|
609 |
+
kui2
|
610 |
+
kui3
|
611 |
+
kui4
|
612 |
+
kun1
|
613 |
+
kun3
|
614 |
+
kun4
|
615 |
+
kuo4
|
616 |
+
l
|
617 |
+
la
|
618 |
+
la1
|
619 |
+
la2
|
620 |
+
la3
|
621 |
+
la4
|
622 |
+
lai2
|
623 |
+
lai4
|
624 |
+
lan2
|
625 |
+
lan3
|
626 |
+
lan4
|
627 |
+
lang1
|
628 |
+
lang2
|
629 |
+
lang3
|
630 |
+
lang4
|
631 |
+
lao1
|
632 |
+
lao2
|
633 |
+
lao3
|
634 |
+
lao4
|
635 |
+
le
|
636 |
+
le1
|
637 |
+
le4
|
638 |
+
lei
|
639 |
+
lei1
|
640 |
+
lei2
|
641 |
+
lei3
|
642 |
+
lei4
|
643 |
+
leng1
|
644 |
+
leng2
|
645 |
+
leng3
|
646 |
+
leng4
|
647 |
+
li
|
648 |
+
li1
|
649 |
+
li2
|
650 |
+
li3
|
651 |
+
li4
|
652 |
+
lia3
|
653 |
+
lian2
|
654 |
+
lian3
|
655 |
+
lian4
|
656 |
+
liang2
|
657 |
+
liang3
|
658 |
+
liang4
|
659 |
+
liao1
|
660 |
+
liao2
|
661 |
+
liao3
|
662 |
+
liao4
|
663 |
+
lie1
|
664 |
+
lie2
|
665 |
+
lie3
|
666 |
+
lie4
|
667 |
+
lin1
|
668 |
+
lin2
|
669 |
+
lin3
|
670 |
+
lin4
|
671 |
+
ling2
|
672 |
+
ling3
|
673 |
+
ling4
|
674 |
+
liu1
|
675 |
+
liu2
|
676 |
+
liu3
|
677 |
+
liu4
|
678 |
+
long1
|
679 |
+
long2
|
680 |
+
long3
|
681 |
+
long4
|
682 |
+
lou1
|
683 |
+
lou2
|
684 |
+
lou3
|
685 |
+
lou4
|
686 |
+
lu1
|
687 |
+
lu2
|
688 |
+
lu3
|
689 |
+
lu4
|
690 |
+
luan2
|
691 |
+
luan3
|
692 |
+
luan4
|
693 |
+
lun1
|
694 |
+
lun2
|
695 |
+
lun4
|
696 |
+
luo1
|
697 |
+
luo2
|
698 |
+
luo3
|
699 |
+
luo4
|
700 |
+
lv2
|
701 |
+
lv3
|
702 |
+
lv4
|
703 |
+
lve3
|
704 |
+
lve4
|
705 |
+
m
|
706 |
+
ma
|
707 |
+
ma1
|
708 |
+
ma2
|
709 |
+
ma3
|
710 |
+
ma4
|
711 |
+
mai2
|
712 |
+
mai3
|
713 |
+
mai4
|
714 |
+
man1
|
715 |
+
man2
|
716 |
+
man3
|
717 |
+
man4
|
718 |
+
mang2
|
719 |
+
mang3
|
720 |
+
mao1
|
721 |
+
mao2
|
722 |
+
mao3
|
723 |
+
mao4
|
724 |
+
me
|
725 |
+
mei2
|
726 |
+
mei3
|
727 |
+
mei4
|
728 |
+
men
|
729 |
+
men1
|
730 |
+
men2
|
731 |
+
men4
|
732 |
+
meng
|
733 |
+
meng1
|
734 |
+
meng2
|
735 |
+
meng3
|
736 |
+
meng4
|
737 |
+
mi1
|
738 |
+
mi2
|
739 |
+
mi3
|
740 |
+
mi4
|
741 |
+
mian2
|
742 |
+
mian3
|
743 |
+
mian4
|
744 |
+
miao1
|
745 |
+
miao2
|
746 |
+
miao3
|
747 |
+
miao4
|
748 |
+
mie1
|
749 |
+
mie4
|
750 |
+
min2
|
751 |
+
min3
|
752 |
+
ming2
|
753 |
+
ming3
|
754 |
+
ming4
|
755 |
+
miu4
|
756 |
+
mo1
|
757 |
+
mo2
|
758 |
+
mo3
|
759 |
+
mo4
|
760 |
+
mou1
|
761 |
+
mou2
|
762 |
+
mou3
|
763 |
+
mu2
|
764 |
+
mu3
|
765 |
+
mu4
|
766 |
+
n
|
767 |
+
n2
|
768 |
+
na1
|
769 |
+
na2
|
770 |
+
na3
|
771 |
+
na4
|
772 |
+
nai2
|
773 |
+
nai3
|
774 |
+
nai4
|
775 |
+
nan1
|
776 |
+
nan2
|
777 |
+
nan3
|
778 |
+
nan4
|
779 |
+
nang1
|
780 |
+
nang2
|
781 |
+
nang3
|
782 |
+
nao1
|
783 |
+
nao2
|
784 |
+
nao3
|
785 |
+
nao4
|
786 |
+
ne
|
787 |
+
ne2
|
788 |
+
ne4
|
789 |
+
nei3
|
790 |
+
nei4
|
791 |
+
nen4
|
792 |
+
neng2
|
793 |
+
ni1
|
794 |
+
ni2
|
795 |
+
ni3
|
796 |
+
ni4
|
797 |
+
nian1
|
798 |
+
nian2
|
799 |
+
nian3
|
800 |
+
nian4
|
801 |
+
niang2
|
802 |
+
niang4
|
803 |
+
niao2
|
804 |
+
niao3
|
805 |
+
niao4
|
806 |
+
nie1
|
807 |
+
nie4
|
808 |
+
nin2
|
809 |
+
ning2
|
810 |
+
ning3
|
811 |
+
ning4
|
812 |
+
niu1
|
813 |
+
niu2
|
814 |
+
niu3
|
815 |
+
niu4
|
816 |
+
nong2
|
817 |
+
nong4
|
818 |
+
nou4
|
819 |
+
nu2
|
820 |
+
nu3
|
821 |
+
nu4
|
822 |
+
nuan3
|
823 |
+
nuo2
|
824 |
+
nuo4
|
825 |
+
nv2
|
826 |
+
nv3
|
827 |
+
nve4
|
828 |
+
o
|
829 |
+
o1
|
830 |
+
o2
|
831 |
+
ou1
|
832 |
+
ou2
|
833 |
+
ou3
|
834 |
+
ou4
|
835 |
+
p
|
836 |
+
pa1
|
837 |
+
pa2
|
838 |
+
pa4
|
839 |
+
pai1
|
840 |
+
pai2
|
841 |
+
pai3
|
842 |
+
pai4
|
843 |
+
pan1
|
844 |
+
pan2
|
845 |
+
pan4
|
846 |
+
pang1
|
847 |
+
pang2
|
848 |
+
pang4
|
849 |
+
pao1
|
850 |
+
pao2
|
851 |
+
pao3
|
852 |
+
pao4
|
853 |
+
pei1
|
854 |
+
pei2
|
855 |
+
pei4
|
856 |
+
pen1
|
857 |
+
pen2
|
858 |
+
pen4
|
859 |
+
peng1
|
860 |
+
peng2
|
861 |
+
peng3
|
862 |
+
peng4
|
863 |
+
pi1
|
864 |
+
pi2
|
865 |
+
pi3
|
866 |
+
pi4
|
867 |
+
pian1
|
868 |
+
pian2
|
869 |
+
pian4
|
870 |
+
piao1
|
871 |
+
piao2
|
872 |
+
piao3
|
873 |
+
piao4
|
874 |
+
pie1
|
875 |
+
pie2
|
876 |
+
pie3
|
877 |
+
pin1
|
878 |
+
pin2
|
879 |
+
pin3
|
880 |
+
pin4
|
881 |
+
ping1
|
882 |
+
ping2
|
883 |
+
po1
|
884 |
+
po2
|
885 |
+
po3
|
886 |
+
po4
|
887 |
+
pou1
|
888 |
+
pu1
|
889 |
+
pu2
|
890 |
+
pu3
|
891 |
+
pu4
|
892 |
+
q
|
893 |
+
qi1
|
894 |
+
qi2
|
895 |
+
qi3
|
896 |
+
qi4
|
897 |
+
qia1
|
898 |
+
qia3
|
899 |
+
qia4
|
900 |
+
qian1
|
901 |
+
qian2
|
902 |
+
qian3
|
903 |
+
qian4
|
904 |
+
qiang1
|
905 |
+
qiang2
|
906 |
+
qiang3
|
907 |
+
qiang4
|
908 |
+
qiao1
|
909 |
+
qiao2
|
910 |
+
qiao3
|
911 |
+
qiao4
|
912 |
+
qie1
|
913 |
+
qie2
|
914 |
+
qie3
|
915 |
+
qie4
|
916 |
+
qin1
|
917 |
+
qin2
|
918 |
+
qin3
|
919 |
+
qin4
|
920 |
+
qing1
|
921 |
+
qing2
|
922 |
+
qing3
|
923 |
+
qing4
|
924 |
+
qiong1
|
925 |
+
qiong2
|
926 |
+
qiu1
|
927 |
+
qiu2
|
928 |
+
qiu3
|
929 |
+
qu1
|
930 |
+
qu2
|
931 |
+
qu3
|
932 |
+
qu4
|
933 |
+
quan1
|
934 |
+
quan2
|
935 |
+
quan3
|
936 |
+
quan4
|
937 |
+
que1
|
938 |
+
que2
|
939 |
+
que4
|
940 |
+
qun2
|
941 |
+
r
|
942 |
+
ran2
|
943 |
+
ran3
|
944 |
+
rang1
|
945 |
+
rang2
|
946 |
+
rang3
|
947 |
+
rang4
|
948 |
+
rao2
|
949 |
+
rao3
|
950 |
+
rao4
|
951 |
+
re2
|
952 |
+
re3
|
953 |
+
re4
|
954 |
+
ren2
|
955 |
+
ren3
|
956 |
+
ren4
|
957 |
+
reng1
|
958 |
+
reng2
|
959 |
+
ri4
|
960 |
+
rong1
|
961 |
+
rong2
|
962 |
+
rong3
|
963 |
+
rou2
|
964 |
+
rou4
|
965 |
+
ru2
|
966 |
+
ru3
|
967 |
+
ru4
|
968 |
+
ruan2
|
969 |
+
ruan3
|
970 |
+
rui3
|
971 |
+
rui4
|
972 |
+
run4
|
973 |
+
ruo4
|
974 |
+
s
|
975 |
+
sa1
|
976 |
+
sa2
|
977 |
+
sa3
|
978 |
+
sa4
|
979 |
+
sai1
|
980 |
+
sai4
|
981 |
+
san1
|
982 |
+
san2
|
983 |
+
san3
|
984 |
+
san4
|
985 |
+
sang1
|
986 |
+
sang3
|
987 |
+
sang4
|
988 |
+
sao1
|
989 |
+
sao2
|
990 |
+
sao3
|
991 |
+
sao4
|
992 |
+
se4
|
993 |
+
sen1
|
994 |
+
seng1
|
995 |
+
sha1
|
996 |
+
sha2
|
997 |
+
sha3
|
998 |
+
sha4
|
999 |
+
shai1
|
1000 |
+
shai2
|
1001 |
+
shai3
|
1002 |
+
shai4
|
1003 |
+
shan1
|
1004 |
+
shan3
|
1005 |
+
shan4
|
1006 |
+
shang
|
1007 |
+
shang1
|
1008 |
+
shang3
|
1009 |
+
shang4
|
1010 |
+
shao1
|
1011 |
+
shao2
|
1012 |
+
shao3
|
1013 |
+
shao4
|
1014 |
+
she1
|
1015 |
+
she2
|
1016 |
+
she3
|
1017 |
+
she4
|
1018 |
+
shei2
|
1019 |
+
shen1
|
1020 |
+
shen2
|
1021 |
+
shen3
|
1022 |
+
shen4
|
1023 |
+
sheng1
|
1024 |
+
sheng2
|
1025 |
+
sheng3
|
1026 |
+
sheng4
|
1027 |
+
shi
|
1028 |
+
shi1
|
1029 |
+
shi2
|
1030 |
+
shi3
|
1031 |
+
shi4
|
1032 |
+
shou1
|
1033 |
+
shou2
|
1034 |
+
shou3
|
1035 |
+
shou4
|
1036 |
+
shu1
|
1037 |
+
shu2
|
1038 |
+
shu3
|
1039 |
+
shu4
|
1040 |
+
shua1
|
1041 |
+
shua2
|
1042 |
+
shua3
|
1043 |
+
shua4
|
1044 |
+
shuai1
|
1045 |
+
shuai3
|
1046 |
+
shuai4
|
1047 |
+
shuan1
|
1048 |
+
shuan4
|
1049 |
+
shuang1
|
1050 |
+
shuang3
|
1051 |
+
shui2
|
1052 |
+
shui3
|
1053 |
+
shui4
|
1054 |
+
shun3
|
1055 |
+
shun4
|
1056 |
+
shuo1
|
1057 |
+
shuo4
|
1058 |
+
si1
|
1059 |
+
si2
|
1060 |
+
si3
|
1061 |
+
si4
|
1062 |
+
song1
|
1063 |
+
song3
|
1064 |
+
song4
|
1065 |
+
sou1
|
1066 |
+
sou3
|
1067 |
+
sou4
|
1068 |
+
su1
|
1069 |
+
su2
|
1070 |
+
su4
|
1071 |
+
suan1
|
1072 |
+
suan4
|
1073 |
+
sui1
|
1074 |
+
sui2
|
1075 |
+
sui3
|
1076 |
+
sui4
|
1077 |
+
sun1
|
1078 |
+
sun3
|
1079 |
+
suo
|
1080 |
+
suo1
|
1081 |
+
suo2
|
1082 |
+
suo3
|
1083 |
+
t
|
1084 |
+
ta1
|
1085 |
+
ta2
|
1086 |
+
ta3
|
1087 |
+
ta4
|
1088 |
+
tai1
|
1089 |
+
tai2
|
1090 |
+
tai4
|
1091 |
+
tan1
|
1092 |
+
tan2
|
1093 |
+
tan3
|
1094 |
+
tan4
|
1095 |
+
tang1
|
1096 |
+
tang2
|
1097 |
+
tang3
|
1098 |
+
tang4
|
1099 |
+
tao1
|
1100 |
+
tao2
|
1101 |
+
tao3
|
1102 |
+
tao4
|
1103 |
+
te4
|
1104 |
+
teng2
|
1105 |
+
ti1
|
1106 |
+
ti2
|
1107 |
+
ti3
|
1108 |
+
ti4
|
1109 |
+
tian1
|
1110 |
+
tian2
|
1111 |
+
tian3
|
1112 |
+
tiao1
|
1113 |
+
tiao2
|
1114 |
+
tiao3
|
1115 |
+
tiao4
|
1116 |
+
tie1
|
1117 |
+
tie2
|
1118 |
+
tie3
|
1119 |
+
tie4
|
1120 |
+
ting1
|
1121 |
+
ting2
|
1122 |
+
ting3
|
1123 |
+
tong1
|
1124 |
+
tong2
|
1125 |
+
tong3
|
1126 |
+
tong4
|
1127 |
+
tou
|
1128 |
+
tou1
|
1129 |
+
tou2
|
1130 |
+
tou4
|
1131 |
+
tu1
|
1132 |
+
tu2
|
1133 |
+
tu3
|
1134 |
+
tu4
|
1135 |
+
tuan1
|
1136 |
+
tuan2
|
1137 |
+
tui1
|
1138 |
+
tui2
|
1139 |
+
tui3
|
1140 |
+
tui4
|
1141 |
+
tun1
|
1142 |
+
tun2
|
1143 |
+
tun4
|
1144 |
+
tuo1
|
1145 |
+
tuo2
|
1146 |
+
tuo3
|
1147 |
+
tuo4
|
1148 |
+
u
|
1149 |
+
v
|
1150 |
+
w
|
1151 |
+
wa
|
1152 |
+
wa1
|
1153 |
+
wa2
|
1154 |
+
wa3
|
1155 |
+
wa4
|
1156 |
+
wai1
|
1157 |
+
wai3
|
1158 |
+
wai4
|
1159 |
+
wan1
|
1160 |
+
wan2
|
1161 |
+
wan3
|
1162 |
+
wan4
|
1163 |
+
wang1
|
1164 |
+
wang2
|
1165 |
+
wang3
|
1166 |
+
wang4
|
1167 |
+
wei1
|
1168 |
+
wei2
|
1169 |
+
wei3
|
1170 |
+
wei4
|
1171 |
+
wen1
|
1172 |
+
wen2
|
1173 |
+
wen3
|
1174 |
+
wen4
|
1175 |
+
weng1
|
1176 |
+
weng4
|
1177 |
+
wo1
|
1178 |
+
wo2
|
1179 |
+
wo3
|
1180 |
+
wo4
|
1181 |
+
wu1
|
1182 |
+
wu2
|
1183 |
+
wu3
|
1184 |
+
wu4
|
1185 |
+
x
|
1186 |
+
xi1
|
1187 |
+
xi2
|
1188 |
+
xi3
|
1189 |
+
xi4
|
1190 |
+
xia1
|
1191 |
+
xia2
|
1192 |
+
xia4
|
1193 |
+
xian1
|
1194 |
+
xian2
|
1195 |
+
xian3
|
1196 |
+
xian4
|
1197 |
+
xiang1
|
1198 |
+
xiang2
|
1199 |
+
xiang3
|
1200 |
+
xiang4
|
1201 |
+
xiao1
|
1202 |
+
xiao2
|
1203 |
+
xiao3
|
1204 |
+
xiao4
|
1205 |
+
xie1
|
1206 |
+
xie2
|
1207 |
+
xie3
|
1208 |
+
xie4
|
1209 |
+
xin1
|
1210 |
+
xin2
|
1211 |
+
xin4
|
1212 |
+
xing1
|
1213 |
+
xing2
|
1214 |
+
xing3
|
1215 |
+
xing4
|
1216 |
+
xiong1
|
1217 |
+
xiong2
|
1218 |
+
xiu1
|
1219 |
+
xiu3
|
1220 |
+
xiu4
|
1221 |
+
xu
|
1222 |
+
xu1
|
1223 |
+
xu2
|
1224 |
+
xu3
|
1225 |
+
xu4
|
1226 |
+
xuan1
|
1227 |
+
xuan2
|
1228 |
+
xuan3
|
1229 |
+
xuan4
|
1230 |
+
xue1
|
1231 |
+
xue2
|
1232 |
+
xue3
|
1233 |
+
xue4
|
1234 |
+
xun1
|
1235 |
+
xun2
|
1236 |
+
xun4
|
1237 |
+
y
|
1238 |
+
ya
|
1239 |
+
ya1
|
1240 |
+
ya2
|
1241 |
+
ya3
|
1242 |
+
ya4
|
1243 |
+
yan1
|
1244 |
+
yan2
|
1245 |
+
yan3
|
1246 |
+
yan4
|
1247 |
+
yang1
|
1248 |
+
yang2
|
1249 |
+
yang3
|
1250 |
+
yang4
|
1251 |
+
yao1
|
1252 |
+
yao2
|
1253 |
+
yao3
|
1254 |
+
yao4
|
1255 |
+
ye1
|
1256 |
+
ye2
|
1257 |
+
ye3
|
1258 |
+
ye4
|
1259 |
+
yi
|
1260 |
+
yi1
|
1261 |
+
yi2
|
1262 |
+
yi3
|
1263 |
+
yi4
|
1264 |
+
yin1
|
1265 |
+
yin2
|
1266 |
+
yin3
|
1267 |
+
yin4
|
1268 |
+
ying1
|
1269 |
+
ying2
|
1270 |
+
ying3
|
1271 |
+
ying4
|
1272 |
+
yo1
|
1273 |
+
yong1
|
1274 |
+
yong2
|
1275 |
+
yong3
|
1276 |
+
yong4
|
1277 |
+
you1
|
1278 |
+
you2
|
1279 |
+
you3
|
1280 |
+
you4
|
1281 |
+
yu1
|
1282 |
+
yu2
|
1283 |
+
yu3
|
1284 |
+
yu4
|
1285 |
+
yuan1
|
1286 |
+
yuan2
|
1287 |
+
yuan3
|
1288 |
+
yuan4
|
1289 |
+
yue1
|
1290 |
+
yue4
|
1291 |
+
yun1
|
1292 |
+
yun2
|
1293 |
+
yun3
|
1294 |
+
yun4
|
1295 |
+
z
|
1296 |
+
za1
|
1297 |
+
za2
|
1298 |
+
za3
|
1299 |
+
zai1
|
1300 |
+
zai3
|
1301 |
+
zai4
|
1302 |
+
zan1
|
1303 |
+
zan2
|
1304 |
+
zan3
|
1305 |
+
zan4
|
1306 |
+
zang1
|
1307 |
+
zang4
|
1308 |
+
zao1
|
1309 |
+
zao2
|
1310 |
+
zao3
|
1311 |
+
zao4
|
1312 |
+
ze2
|
1313 |
+
ze4
|
1314 |
+
zei2
|
1315 |
+
zen3
|
1316 |
+
zeng1
|
1317 |
+
zeng4
|
1318 |
+
zha1
|
1319 |
+
zha2
|
1320 |
+
zha3
|
1321 |
+
zha4
|
1322 |
+
zhai1
|
1323 |
+
zhai2
|
1324 |
+
zhai3
|
1325 |
+
zhai4
|
1326 |
+
zhan1
|
1327 |
+
zhan2
|
1328 |
+
zhan3
|
1329 |
+
zhan4
|
1330 |
+
zhang1
|
1331 |
+
zhang2
|
1332 |
+
zhang3
|
1333 |
+
zhang4
|
1334 |
+
zhao1
|
1335 |
+
zhao2
|
1336 |
+
zhao3
|
1337 |
+
zhao4
|
1338 |
+
zhe
|
1339 |
+
zhe1
|
1340 |
+
zhe2
|
1341 |
+
zhe3
|
1342 |
+
zhe4
|
1343 |
+
zhen1
|
1344 |
+
zhen2
|
1345 |
+
zhen3
|
1346 |
+
zhen4
|
1347 |
+
zheng1
|
1348 |
+
zheng2
|
1349 |
+
zheng3
|
1350 |
+
zheng4
|
1351 |
+
zhi1
|
1352 |
+
zhi2
|
1353 |
+
zhi3
|
1354 |
+
zhi4
|
1355 |
+
zhong1
|
1356 |
+
zhong2
|
1357 |
+
zhong3
|
1358 |
+
zhong4
|
1359 |
+
zhou1
|
1360 |
+
zhou2
|
1361 |
+
zhou3
|
1362 |
+
zhou4
|
1363 |
+
zhu1
|
1364 |
+
zhu2
|
1365 |
+
zhu3
|
1366 |
+
zhu4
|
1367 |
+
zhua1
|
1368 |
+
zhua2
|
1369 |
+
zhua3
|
1370 |
+
zhuai1
|
1371 |
+
zhuai3
|
1372 |
+
zhuai4
|
1373 |
+
zhuan1
|
1374 |
+
zhuan2
|
1375 |
+
zhuan3
|
1376 |
+
zhuan4
|
1377 |
+
zhuang1
|
1378 |
+
zhuang4
|
1379 |
+
zhui1
|
1380 |
+
zhui4
|
1381 |
+
zhun1
|
1382 |
+
zhun2
|
1383 |
+
zhun3
|
1384 |
+
zhuo1
|
1385 |
+
zhuo2
|
1386 |
+
zi
|
1387 |
+
zi1
|
1388 |
+
zi2
|
1389 |
+
zi3
|
1390 |
+
zi4
|
1391 |
+
zong1
|
1392 |
+
zong2
|
1393 |
+
zong3
|
1394 |
+
zong4
|
1395 |
+
zou1
|
1396 |
+
zou2
|
1397 |
+
zou3
|
1398 |
+
zou4
|
1399 |
+
zu1
|
1400 |
+
zu2
|
1401 |
+
zu3
|
1402 |
+
zuan1
|
1403 |
+
zuan3
|
1404 |
+
zuan4
|
1405 |
+
zui2
|
1406 |
+
zui3
|
1407 |
+
zui4
|
1408 |
+
zun1
|
1409 |
+
zuo
|
1410 |
+
zuo1
|
1411 |
+
zuo2
|
1412 |
+
zuo3
|
1413 |
+
zuo4
|
1414 |
+
{
|
1415 |
+
~
|
1416 |
+
¡
|
1417 |
+
¢
|
1418 |
+
£
|
1419 |
+
¥
|
1420 |
+
§
|
1421 |
+
¨
|
1422 |
+
©
|
1423 |
+
«
|
1424 |
+
®
|
1425 |
+
¯
|
1426 |
+
°
|
1427 |
+
±
|
1428 |
+
²
|
1429 |
+
³
|
1430 |
+
´
|
1431 |
+
µ
|
1432 |
+
·
|
1433 |
+
¹
|
1434 |
+
º
|
1435 |
+
»
|
1436 |
+
¼
|
1437 |
+
½
|
1438 |
+
¾
|
1439 |
+
¿
|
1440 |
+
À
|
1441 |
+
Á
|
1442 |
+
Â
|
1443 |
+
Ã
|
1444 |
+
Ä
|
1445 |
+
Å
|
1446 |
+
Æ
|
1447 |
+
Ç
|
1448 |
+
È
|
1449 |
+
É
|
1450 |
+
Ê
|
1451 |
+
Í
|
1452 |
+
Î
|
1453 |
+
Ñ
|
1454 |
+
Ó
|
1455 |
+
Ö
|
1456 |
+
×
|
1457 |
+
Ø
|
1458 |
+
Ú
|
1459 |
+
Ü
|
1460 |
+
Ý
|
1461 |
+
Þ
|
1462 |
+
ß
|
1463 |
+
à
|
1464 |
+
á
|
1465 |
+
â
|
1466 |
+
ã
|
1467 |
+
ä
|
1468 |
+
å
|
1469 |
+
æ
|
1470 |
+
ç
|
1471 |
+
è
|
1472 |
+
é
|
1473 |
+
ê
|
1474 |
+
ë
|
1475 |
+
ì
|
1476 |
+
í
|
1477 |
+
î
|
1478 |
+
ï
|
1479 |
+
ð
|
1480 |
+
ñ
|
1481 |
+
ò
|
1482 |
+
ó
|
1483 |
+
ô
|
1484 |
+
õ
|
1485 |
+
ö
|
1486 |
+
ø
|
1487 |
+
ù
|
1488 |
+
ú
|
1489 |
+
û
|
1490 |
+
ü
|
1491 |
+
ý
|
1492 |
+
Ā
|
1493 |
+
ā
|
1494 |
+
ă
|
1495 |
+
ą
|
1496 |
+
ć
|
1497 |
+
Č
|
1498 |
+
č
|
1499 |
+
Đ
|
1500 |
+
đ
|
1501 |
+
ē
|
1502 |
+
ė
|
1503 |
+
ę
|
1504 |
+
ě
|
1505 |
+
ĝ
|
1506 |
+
ğ
|
1507 |
+
ħ
|
1508 |
+
ī
|
1509 |
+
į
|
1510 |
+
İ
|
1511 |
+
ı
|
1512 |
+
Ł
|
1513 |
+
ł
|
1514 |
+
ń
|
1515 |
+
ņ
|
1516 |
+
ň
|
1517 |
+
ŋ
|
1518 |
+
Ō
|
1519 |
+
ō
|
1520 |
+
ő
|
1521 |
+
œ
|
1522 |
+
ř
|
1523 |
+
Ś
|
1524 |
+
ś
|
1525 |
+
Ş
|
1526 |
+
ş
|
1527 |
+
Š
|
1528 |
+
š
|
1529 |
+
Ť
|
1530 |
+
ť
|
1531 |
+
ũ
|
1532 |
+
ū
|
1533 |
+
ź
|
1534 |
+
Ż
|
1535 |
+
ż
|
1536 |
+
Ž
|
1537 |
+
ž
|
1538 |
+
ơ
|
1539 |
+
ư
|
1540 |
+
ǎ
|
1541 |
+
ǐ
|
1542 |
+
ǒ
|
1543 |
+
ǔ
|
1544 |
+
ǚ
|
1545 |
+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+
ώ
|
1626 |
+
ϕ
|
1627 |
+
ϵ
|
1628 |
+
Ё
|
1629 |
+
А
|
1630 |
+
Б
|
1631 |
+
В
|
1632 |
+
Г
|
1633 |
+
Д
|
1634 |
+
Е
|
1635 |
+
Ж
|
1636 |
+
З
|
1637 |
+
И
|
1638 |
+
Й
|
1639 |
+
К
|
1640 |
+
Л
|
1641 |
+
М
|
1642 |
+
Н
|
1643 |
+
О
|
1644 |
+
П
|
1645 |
+
Р
|
1646 |
+
С
|
1647 |
+
Т
|
1648 |
+
У
|
1649 |
+
Ф
|
1650 |
+
Х
|
1651 |
+
Ц
|
1652 |
+
Ч
|
1653 |
+
Ш
|
1654 |
+
Щ
|
1655 |
+
Ы
|
1656 |
+
Ь
|
1657 |
+
Э
|
1658 |
+
Ю
|
1659 |
+
Я
|
1660 |
+
а
|
1661 |
+
б
|
1662 |
+
в
|
1663 |
+
г
|
1664 |
+
д
|
1665 |
+
е
|
1666 |
+
ж
|
1667 |
+
з
|
1668 |
+
и
|
1669 |
+
й
|
1670 |
+
к
|
1671 |
+
л
|
1672 |
+
м
|
1673 |
+
н
|
1674 |
+
о
|
1675 |
+
п
|
1676 |
+
р
|
1677 |
+
с
|
1678 |
+
т
|
1679 |
+
у
|
1680 |
+
ф
|
1681 |
+
х
|
1682 |
+
ц
|
1683 |
+
ч
|
1684 |
+
ш
|
1685 |
+
щ
|
1686 |
+
ъ
|
1687 |
+
ы
|
1688 |
+
ь
|
1689 |
+
э
|
1690 |
+
ю
|
1691 |
+
я
|
1692 |
+
ё
|
1693 |
+
і
|
1694 |
+
ְ
|
1695 |
+
ִ
|
1696 |
+
ֵ
|
1697 |
+
ֶ
|
1698 |
+
ַ
|
1699 |
+
ָ
|
1700 |
+
ֹ
|
1701 |
+
|
1702 |
+
|
1703 |
+
|
1704 |
+
|
1705 |
+
|
1706 |
+
<
|
1707 |
+
^
|
1708 |
+
`
|
1709 |
+
|
|
1710 |
+
}
|
1711 |
+
|
1712 |
+
ʼ
|
1713 |
+
̮
|
1714 |
+
ँ
|
1715 |
+
ं
|
1716 |
+
ः
|
1717 |
+
अ
|
1718 |
+
आ
|
1719 |
+
इ
|
1720 |
+
ई
|
1721 |
+
उ
|
1722 |
+
ऊ
|
1723 |
+
ऋ
|
1724 |
+
ऍ
|
1725 |
+
ऎ
|
1726 |
+
ए
|
1727 |
+
ऐ
|
1728 |
+
ऑ
|
1729 |
+
ऒ
|
1730 |
+
ओ
|
1731 |
+
औ
|
1732 |
+
क
|
1733 |
+
ख
|
1734 |
+
ग
|
1735 |
+
घ
|
1736 |
+
ङ
|
1737 |
+
च
|
1738 |
+
छ
|
1739 |
+
ज
|
1740 |
+
झ
|
1741 |
+
ञ
|
1742 |
+
ट
|
1743 |
+
ठ
|
1744 |
+
ड
|
1745 |
+
ढ
|
1746 |
+
ण
|
1747 |
+
त
|
1748 |
+
थ
|
1749 |
+
द
|
1750 |
+
ध
|
1751 |
+
न
|
1752 |
+
ऩ
|
1753 |
+
प
|
1754 |
+
फ
|
1755 |
+
ब
|
1756 |
+
भ
|
1757 |
+
म
|
1758 |
+
य
|
1759 |
+
र
|
1760 |
+
ऱ
|
1761 |
+
ल
|
1762 |
+
ळ
|
1763 |
+
ऴ
|
1764 |
+
व
|
1765 |
+
श
|
1766 |
+
ष
|
1767 |
+
स
|
1768 |
+
ह
|
1769 |
+
ऺ
|
1770 |
+
ऻ
|
1771 |
+
़
|
1772 |
+
ऽ
|
1773 |
+
ा
|
1774 |
+
ि
|
1775 |
+
ी
|
1776 |
+
ु
|
1777 |
+
ू
|
1778 |
+
ृ
|
1779 |
+
ॄ
|
1780 |
+
ॅ
|
1781 |
+
ॆ
|
1782 |
+
े
|
1783 |
+
ै
|
1784 |
+
ॉ
|
1785 |
+
ॊ
|
1786 |
+
ो
|
1787 |
+
ौ
|
1788 |
+
्
|
1789 |
+
ॐ
|
1790 |
+
॑
|
1791 |
+
॒
|
1792 |
+
॔
|
1793 |
+
ॕ
|
1794 |
+
ॖ
|
1795 |
+
क़
|
1796 |
+
ख़
|
1797 |
+
ग़
|
1798 |
+
ज़
|
1799 |
+
ड़
|
1800 |
+
ढ़
|
1801 |
+
फ़
|
1802 |
+
य़
|
1803 |
+
ॠ
|
1804 |
+
।
|
1805 |
+
॥
|
1806 |
+
०
|
1807 |
+
१
|
1808 |
+
२
|
1809 |
+
३
|
1810 |
+
४
|
1811 |
+
५
|
1812 |
+
६
|
1813 |
+
७
|
1814 |
+
८
|
1815 |
+
९
|
1816 |
+
॰
|
1817 |
+
ॲ
|
1818 |
+
ঁ
|
1819 |
+
ং
|
1820 |
+
ঃ
|
1821 |
+
অ
|
1822 |
+
আ
|
1823 |
+
ই
|
1824 |
+
ঈ
|
1825 |
+
উ
|
1826 |
+
ঊ
|
1827 |
+
ঋ
|
1828 |
+
ঌ
|
1829 |
+
|
1830 |
+
এ
|
1831 |
+
ঐ
|
1832 |
+
ও
|
1833 |
+
ঔ
|
1834 |
+
ক
|
1835 |
+
খ
|
1836 |
+
গ
|
1837 |
+
ঘ
|
1838 |
+
ঙ
|
1839 |
+
চ
|
1840 |
+
ছ
|
1841 |
+
জ
|
1842 |
+
ঝ
|
1843 |
+
ঞ
|
1844 |
+
ট
|
1845 |
+
ঠ
|
1846 |
+
ড
|
1847 |
+
ঢ
|
1848 |
+
ণ
|
1849 |
+
ত
|
1850 |
+
থ
|
1851 |
+
দ
|
1852 |
+
ধ
|
1853 |
+
ন
|
1854 |
+
প
|
1855 |
+
ফ
|
1856 |
+
ব
|
1857 |
+
ভ
|
1858 |
+
ম
|
1859 |
+
য
|
1860 |
+
র
|
1861 |
+
ল
|
1862 |
+
|
1863 |
+
শ
|
1864 |
+
ষ
|
1865 |
+
স
|
1866 |
+
হ
|
1867 |
+
়
|
1868 |
+
ঽ
|
1869 |
+
া
|
1870 |
+
ি
|
1871 |
+
ী
|
1872 |
+
ু
|
1873 |
+
ূ
|
1874 |
+
ৃ
|
1875 |
+
ৄ
|
1876 |
+
|
1877 |
+
ে
|
1878 |
+
ৈ
|
1879 |
+
ো
|
1880 |
+
ৌ
|
1881 |
+
্
|
1882 |
+
ৎ
|
1883 |
+
ৗ
|
1884 |
+
ড়
|
1885 |
+
ঢ়
|
1886 |
+
য়
|
1887 |
+
০
|
1888 |
+
১
|
1889 |
+
২
|
1890 |
+
৩
|
1891 |
+
৪
|
1892 |
+
৫
|
1893 |
+
৬
|
1894 |
+
৭
|
1895 |
+
৮
|
1896 |
+
৯
|
1897 |
+
ৰ
|
1898 |
+
ৱ
|
1899 |
+
৲
|
1900 |
+
৷
|
1901 |
+
৹
|
1902 |
+
৻
|
1903 |
+
ਂ
|
1904 |
+
ਃ
|
1905 |
+
ਅ
|
1906 |
+
ਆ
|
1907 |
+
ਇ
|
1908 |
+
ਈ
|
1909 |
+
ਉ
|
1910 |
+
ਊ
|
1911 |
+
ਏ
|
1912 |
+
ਐ
|
1913 |
+
ਓ
|
1914 |
+
ਔ
|
1915 |
+
ਕ
|
1916 |
+
ਖ
|
1917 |
+
ਗ
|
1918 |
+
ਘ
|
1919 |
+
ਙ
|
1920 |
+
ਚ
|
1921 |
+
ਛ
|
1922 |
+
ਜ
|
1923 |
+
ਝ
|
1924 |
+
ਞ
|
1925 |
+
ਟ
|
1926 |
+
ਠ
|
1927 |
+
ਡ
|
1928 |
+
ਢ
|
1929 |
+
ਣ
|
1930 |
+
ਤ
|
1931 |
+
ਥ
|
1932 |
+
ਦ
|
1933 |
+
ਧ
|
1934 |
+
ਨ
|
1935 |
+
ਪ
|
1936 |
+
ਫ
|
1937 |
+
ਬ
|
1938 |
+
ਭ
|
1939 |
+
ਮ
|
1940 |
+
ਯ
|
1941 |
+
ਰ
|
1942 |
+
ਲ
|
1943 |
+
ਲ਼
|
1944 |
+
ਵ
|
1945 |
+
ਸ਼
|
1946 |
+
ਸ
|
1947 |
+
ਹ
|
1948 |
+
਼
|
1949 |
+
ਾ
|
1950 |
+
ਿ
|
1951 |
+
ੀ
|
1952 |
+
ੁ
|
1953 |
+
ੂ
|
1954 |
+
ੇ
|
1955 |
+
ੈ
|
1956 |
+
ੋ
|
1957 |
+
ੌ
|
1958 |
+
੍
|
1959 |
+
ੑ
|
1960 |
+
ਖ਼
|
1961 |
+
ਗ਼
|
1962 |
+
ਜ਼
|
1963 |
+
ੜ
|
1964 |
+
ਫ਼
|
1965 |
+
ੰ
|
1966 |
+
ੱ
|
1967 |
+
ੲ
|
1968 |
+
ੳ
|
1969 |
+
ઁ
|
1970 |
+
ં
|
1971 |
+
ઃ
|
1972 |
+
અ
|
1973 |
+
આ
|
1974 |
+
ઇ
|
1975 |
+
ઈ
|
1976 |
+
ઉ
|
1977 |
+
ઊ
|
1978 |
+
ઋ
|
1979 |
+
ઍ
|
1980 |
+
એ
|
1981 |
+
ઐ
|
1982 |
+
ઑ
|
1983 |
+
ઓ
|
1984 |
+
ઔ
|
1985 |
+
ક
|
1986 |
+
ખ
|
1987 |
+
ગ
|
1988 |
+
ઘ
|
1989 |
+
ચ
|
1990 |
+
છ
|
1991 |
+
જ
|
1992 |
+
ઝ
|
1993 |
+
ઞ
|
1994 |
+
ટ
|
1995 |
+
ઠ
|
1996 |
+
ડ
|
1997 |
+
ઢ
|
1998 |
+
ણ
|
1999 |
+
ત
|
2000 |
+
થ
|
2001 |
+
દ
|
2002 |
+
ધ
|
2003 |
+
ન
|
2004 |
+
પ
|
2005 |
+
ફ
|
2006 |
+
બ
|
2007 |
+
ભ
|
2008 |
+
મ
|
2009 |
+
ય
|
2010 |
+
ર
|
2011 |
+
લ
|
2012 |
+
ળ
|
2013 |
+
વ
|
2014 |
+
શ
|
2015 |
+
ષ
|
2016 |
+
સ
|
2017 |
+
હ
|
2018 |
+
઼
|
2019 |
+
ા
|
2020 |
+
િ
|
2021 |
+
ી
|
2022 |
+
ુ
|
2023 |
+
ૂ
|
2024 |
+
ૃ
|
2025 |
+
ૄ
|
2026 |
+
ૅ
|
2027 |
+
ે
|
2028 |
+
ૈ
|
2029 |
+
ૉ
|
2030 |
+
ો
|
2031 |
+
ૌ
|
2032 |
+
્
|
2033 |
+
ૐ
|
2034 |
+
ૠ
|
2035 |
+
૧
|
2036 |
+
૨
|
2037 |
+
૪
|
2038 |
+
૫
|
2039 |
+
ଁ
|
2040 |
+
ଂ
|
2041 |
+
ଃ
|
2042 |
+
ଅ
|
2043 |
+
ଆ
|
2044 |
+
ଇ
|
2045 |
+
ଈ
|
2046 |
+
ଉ
|
2047 |
+
ଊ
|
2048 |
+
ଋ
|
2049 |
+
ଏ
|
2050 |
+
ଐ
|
2051 |
+
ଓ
|
2052 |
+
ଔ
|
2053 |
+
କ
|
2054 |
+
ଖ
|
2055 |
+
ଗ
|
2056 |
+
ଘ
|
2057 |
+
ଙ
|
2058 |
+
ଚ
|
2059 |
+
ଛ
|
2060 |
+
ଜ
|
2061 |
+
ଝ
|
2062 |
+
ଞ
|
2063 |
+
ଟ
|
2064 |
+
ଠ
|
2065 |
+
ଡ
|
2066 |
+
ଢ
|
2067 |
+
ଣ
|
2068 |
+
ତ
|
2069 |
+
ଥ
|
2070 |
+
ଦ
|
2071 |
+
ଧ
|
2072 |
+
ନ
|
2073 |
+
ପ
|
2074 |
+
ଫ
|
2075 |
+
ବ
|
2076 |
+
ଭ
|
2077 |
+
ମ
|
2078 |
+
ଯ
|
2079 |
+
ର
|
2080 |
+
ଲ
|
2081 |
+
ଳ
|
2082 |
+
ଵ
|
2083 |
+
ଶ
|
2084 |
+
ଷ
|
2085 |
+
ସ
|
2086 |
+
ହ
|
2087 |
+
଼
|
2088 |
+
ା
|
2089 |
+
ି
|
2090 |
+
ୀ
|
2091 |
+
ୁ
|
2092 |
+
ୂ
|
2093 |
+
ୃ
|
2094 |
+
ୄ
|
2095 |
+
େ
|
2096 |
+
ୈ
|
2097 |
+
ୋ
|
2098 |
+
ୌ
|
2099 |
+
୍
|
2100 |
+
ୖ
|
2101 |
+
ୗ
|
2102 |
+
ଡ଼
|
2103 |
+
ଢ଼
|
2104 |
+
ୟ
|
2105 |
+
ୠ
|
2106 |
+
୦
|
2107 |
+
୧
|
2108 |
+
୨
|
2109 |
+
୪
|
2110 |
+
୫
|
2111 |
+
୬
|
2112 |
+
୮
|
2113 |
+
ୱ
|
2114 |
+
ஃ
|
2115 |
+
அ
|
2116 |
+
ஆ
|
2117 |
+
இ
|
2118 |
+
ஈ
|
2119 |
+
உ
|
2120 |
+
ஊ
|
2121 |
+
எ
|
2122 |
+
ஏ
|
2123 |
+
ஐ
|
2124 |
+
ஒ
|
2125 |
+
ஓ
|
2126 |
+
ஔ
|
2127 |
+
க
|
2128 |
+
ங
|
2129 |
+
ச
|
2130 |
+
ஜ
|
2131 |
+
ஞ
|
2132 |
+
ட
|
2133 |
+
ண
|
2134 |
+
த
|
2135 |
+
ந
|
2136 |
+
ன
|
2137 |
+
ப
|
2138 |
+
ம
|
2139 |
+
ய
|
2140 |
+
ர
|
2141 |
+
ற
|
2142 |
+
ல
|
2143 |
+
ள
|
2144 |
+
ழ
|
2145 |
+
வ
|
2146 |
+
ஷ
|
2147 |
+
ஸ
|
2148 |
+
ஹ
|
2149 |
+
ா
|
2150 |
+
ி
|
2151 |
+
ீ
|
2152 |
+
ு
|
2153 |
+
ூ
|
2154 |
+
ெ
|
2155 |
+
ே
|
2156 |
+
ை
|
2157 |
+
ொ
|
2158 |
+
ோ
|
2159 |
+
ௌ
|
2160 |
+
்
|
2161 |
+
ௗ
|
2162 |
+
௦
|
2163 |
+
ఁ
|
2164 |
+
ం
|
2165 |
+
ః
|
2166 |
+
అ
|
2167 |
+
ఆ
|
2168 |
+
ఇ
|
2169 |
+
ఈ
|
2170 |
+
ఉ
|
2171 |
+
ఊ
|
2172 |
+
ఋ
|
2173 |
+
ఎ
|
2174 |
+
ఏ
|
2175 |
+
ఐ
|
2176 |
+
ఒ
|
2177 |
+
ఓ
|
2178 |
+
ఔ
|
2179 |
+
క
|
2180 |
+
ఖ
|
2181 |
+
గ
|
2182 |
+
ఘ
|
2183 |
+
ఙ
|
2184 |
+
చ
|
2185 |
+
ఛ
|
2186 |
+
జ
|
2187 |
+
ఝ
|
2188 |
+
ఞ
|
2189 |
+
ట
|
2190 |
+
ఠ
|
2191 |
+
డ
|
2192 |
+
ఢ
|
2193 |
+
ణ
|
2194 |
+
త
|
2195 |
+
థ
|
2196 |
+
ద
|
2197 |
+
ధ
|
2198 |
+
న
|
2199 |
+
ప
|
2200 |
+
ఫ
|
2201 |
+
బ
|
2202 |
+
భ
|
2203 |
+
మ
|
2204 |
+
య
|
2205 |
+
ర
|
2206 |
+
ఱ
|
2207 |
+
ల
|
2208 |
+
ళ
|
2209 |
+
వ
|
2210 |
+
శ
|
2211 |
+
ష
|
2212 |
+
స
|
2213 |
+
హ
|
2214 |
+
ఽ
|
2215 |
+
ా
|
2216 |
+
ి
|
2217 |
+
ీ
|
2218 |
+
ు
|
2219 |
+
ూ
|
2220 |
+
ృ
|
2221 |
+
ౄ
|
2222 |
+
ె
|
2223 |
+
ే
|
2224 |
+
ై
|
2225 |
+
ొ
|
2226 |
+
ో
|
2227 |
+
ౌ
|
2228 |
+
్
|
2229 |
+
ౕ
|
2230 |
+
ౖ
|
2231 |
+
ౙ
|
2232 |
+
ౠ
|
2233 |
+
౦
|
2234 |
+
౩
|
2235 |
+
ಂ
|
2236 |
+
ಃ
|
2237 |
+
ಅ
|
2238 |
+
ಆ
|
2239 |
+
ಇ
|
2240 |
+
ಈ
|
2241 |
+
ಉ
|
2242 |
+
ಊ
|
2243 |
+
ಋ
|
2244 |
+
ಎ
|
2245 |
+
ಏ
|
2246 |
+
ಐ
|
2247 |
+
ಒ
|
2248 |
+
ಓ
|
2249 |
+
ಔ
|
2250 |
+
ಕ
|
2251 |
+
ಖ
|
2252 |
+
ಗ
|
2253 |
+
ಘ
|
2254 |
+
ಙ
|
2255 |
+
ಚ
|
2256 |
+
ಛ
|
2257 |
+
ಜ
|
2258 |
+
ಝ
|
2259 |
+
ಞ
|
2260 |
+
ಟ
|
2261 |
+
ಠ
|
2262 |
+
ಡ
|
2263 |
+
ಢ
|
2264 |
+
ಣ
|
2265 |
+
ತ
|
2266 |
+
ಥ
|
2267 |
+
ದ
|
2268 |
+
ಧ
|
2269 |
+
ನ
|
2270 |
+
ಪ
|
2271 |
+
ಫ
|
2272 |
+
ಬ
|
2273 |
+
ಭ
|
2274 |
+
ಮ
|
2275 |
+
ಯ
|
2276 |
+
ರ
|
2277 |
+
ಱ
|
2278 |
+
ಲ
|
2279 |
+
ಳ
|
2280 |
+
ವ
|
2281 |
+
ಶ
|
2282 |
+
ಷ
|
2283 |
+
ಸ
|
2284 |
+
ಹ
|
2285 |
+
಼
|
2286 |
+
ಽ
|
2287 |
+
ಾ
|
2288 |
+
ಿ
|
2289 |
+
ೀ
|
2290 |
+
ು
|
2291 |
+
ೂ
|
2292 |
+
ೃ
|
2293 |
+
ೆ
|
2294 |
+
ೇ
|
2295 |
+
ೈ
|
2296 |
+
ೊ
|
2297 |
+
ೋ
|
2298 |
+
ೌ
|
2299 |
+
್
|
2300 |
+
ೕ
|
2301 |
+
ೖ
|
2302 |
+
ೞ
|
2303 |
+
ೠ
|
2304 |
+
೦
|
2305 |
+
೧
|
2306 |
+
೨
|
2307 |
+
೩
|
2308 |
+
೪
|
2309 |
+
೫
|
2310 |
+
೬
|
2311 |
+
೭
|
2312 |
+
೮
|
2313 |
+
೯
|
2314 |
+
ം
|
2315 |
+
ഃ
|
2316 |
+
അ
|
2317 |
+
ആ
|
2318 |
+
ഇ
|
2319 |
+
ഈ
|
2320 |
+
ഉ
|
2321 |
+
ഊ
|
2322 |
+
ഋ
|
2323 |
+
എ
|
2324 |
+
ഏ
|
2325 |
+
ഐ
|
2326 |
+
ഒ
|
2327 |
+
ഓ
|
2328 |
+
ഔ
|
2329 |
+
ക
|
2330 |
+
ഖ
|
2331 |
+
ഗ
|
2332 |
+
ഘ
|
2333 |
+
ങ
|
2334 |
+
ച
|
2335 |
+
ഛ
|
2336 |
+
ജ
|
2337 |
+
ഝ
|
2338 |
+
ഞ
|
2339 |
+
ട
|
2340 |
+
ഠ
|
2341 |
+
ഡ
|
2342 |
+
ഢ
|
2343 |
+
ണ
|
2344 |
+
ത
|
2345 |
+
ഥ
|
2346 |
+
ദ
|
2347 |
+
ധ
|
2348 |
+
ന
|
2349 |
+
പ
|
2350 |
+
ഫ
|
2351 |
+
ബ
|
2352 |
+
ഭ
|
2353 |
+
മ
|
2354 |
+
യ
|
2355 |
+
ര
|
2356 |
+
റ
|
2357 |
+
ല
|
2358 |
+
ള
|
2359 |
+
ഴ
|
2360 |
+
വ
|
2361 |
+
ശ
|
2362 |
+
ഷ
|
2363 |
+
സ
|
2364 |
+
ഹ
|
2365 |
+
ാ
|
2366 |
+
ി
|
2367 |
+
ീ
|
2368 |
+
ു
|
2369 |
+
ൂ
|
2370 |
+
ൃ
|
2371 |
+
െ
|
2372 |
+
േ
|
2373 |
+
ൈ
|
2374 |
+
���
|
2375 |
+
ോ
|
2376 |
+
ൌ
|
2377 |
+
്
|
2378 |
+
ൎ
|
2379 |
+
ൗ
|
2380 |
+
ൟ
|
2381 |
+
ൺ
|
2382 |
+
ൻ
|
2383 |
+
ർ
|
2384 |
+
ൽ
|
2385 |
+
ൾ
|
2386 |
+
ൿ
|
2387 |
+
|
2388 |
+
|
2389 |
+
|
2390 |
+
|
2391 |
+
|
2392 |
+
|
2393 |
+
›
|
2394 |
+
⇒
|
2395 |
+
|
2396 |
+
|
2397 |
+
|
2398 |
+
📯
|
2399 |
+
읽
|
2400 |
+
임
|
2401 |
+
입
|
2402 |
+
있
|
2403 |
+
자
|
2404 |
+
작
|
2405 |
+
잔
|
2406 |
+
잖
|
2407 |
+
잘
|
2408 |
+
잡
|
2409 |
+
잤
|
2410 |
+
장
|
2411 |
+
재
|
2412 |
+
저
|
2413 |
+
전
|
2414 |
+
점
|
2415 |
+
정
|
2416 |
+
제
|
2417 |
+
져
|
2418 |
+
졌
|
2419 |
+
조
|
2420 |
+
족
|
2421 |
+
좀
|
2422 |
+
종
|
2423 |
+
좋
|
2424 |
+
죠
|
2425 |
+
주
|
2426 |
+
준
|
2427 |
+
줄
|
2428 |
+
중
|
2429 |
+
줘
|
2430 |
+
즈
|
2431 |
+
즐
|
2432 |
+
즘
|
2433 |
+
지
|
2434 |
+
진
|
2435 |
+
집
|
2436 |
+
짜
|
2437 |
+
짝
|
2438 |
+
쩌
|
2439 |
+
쪼
|
2440 |
+
쪽
|
2441 |
+
쫌
|
2442 |
+
쭈
|
2443 |
+
쯔
|
2444 |
+
찌
|
2445 |
+
찍
|
2446 |
+
차
|
2447 |
+
착
|
2448 |
+
찾
|
2449 |
+
책
|
2450 |
+
처
|
2451 |
+
천
|
2452 |
+
철
|
2453 |
+
체
|
2454 |
+
쳐
|
2455 |
+
쳤
|
2456 |
+
초
|
2457 |
+
촌
|
2458 |
+
추
|
2459 |
+
출
|
2460 |
+
춤
|
2461 |
+
춥
|
2462 |
+
춰
|
2463 |
+
치
|
2464 |
+
친
|
2465 |
+
칠
|
2466 |
+
침
|
2467 |
+
칩
|
2468 |
+
칼
|
2469 |
+
커
|
2470 |
+
켓
|
2471 |
+
코
|
2472 |
+
콩
|
2473 |
+
쿠
|
2474 |
+
퀴
|
2475 |
+
크
|
2476 |
+
큰
|
2477 |
+
큽
|
2478 |
+
키
|
2479 |
+
킨
|
2480 |
+
타
|
2481 |
+
태
|
2482 |
+
터
|
2483 |
+
턴
|
2484 |
+
털
|
2485 |
+
테
|
2486 |
+
토
|
2487 |
+
통
|
2488 |
+
투
|
2489 |
+
트
|
2490 |
+
특
|
2491 |
+
튼
|
2492 |
+
틀
|
2493 |
+
티
|
2494 |
+
팀
|
2495 |
+
파
|
2496 |
+
팔
|
2497 |
+
패
|
2498 |
+
페
|
2499 |
+
펜
|
2500 |
+
펭
|
2501 |
+
평
|
2502 |
+
포
|
2503 |
+
폭
|
2504 |
+
표
|
2505 |
+
품
|
2506 |
+
풍
|
2507 |
+
프
|
2508 |
+
플
|
2509 |
+
피
|
2510 |
+
필
|
2511 |
+
하
|
2512 |
+
학
|
2513 |
+
한
|
2514 |
+
할
|
2515 |
+
함
|
2516 |
+
합
|
2517 |
+
항
|
2518 |
+
해
|
2519 |
+
햇
|
2520 |
+
했
|
2521 |
+
행
|
2522 |
+
허
|
2523 |
+
험
|
2524 |
+
형
|
2525 |
+
혜
|
2526 |
+
호
|
2527 |
+
혼
|
2528 |
+
홀
|
2529 |
+
화
|
2530 |
+
회
|
2531 |
+
획
|
2532 |
+
후
|
2533 |
+
휴
|
2534 |
+
흐
|
2535 |
+
흔
|
2536 |
+
희
|
2537 |
+
히
|
2538 |
+
힘
|
2539 |
+
ﷺ
|
2540 |
+
ﷻ
|
2541 |
+
!
|
2542 |
+
,
|
2543 |
+
?
|
2544 |
+
�
|
2545 |
+
𠮶
|
config.json
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"INF5Model"
|
4 |
+
],
|
5 |
+
"auto_map": {
|
6 |
+
"AutoConfig": "model.INF5Config",
|
7 |
+
"AutoModel": "model.INF5Model"
|
8 |
+
},
|
9 |
+
"ckpt_path": "checkpoints/model_best.pt",
|
10 |
+
"model_type": "inf5",
|
11 |
+
"remove_sil": true,
|
12 |
+
"speed": 1.0,
|
13 |
+
"torch_dtype": "float32",
|
14 |
+
"transformers_version": "4.49.0",
|
15 |
+
"vocab_path": "checkpoints/vocab.txt"
|
16 |
+
}
|
f5_tts/api.py
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import random
|
2 |
+
import sys
|
3 |
+
from importlib.resources import files
|
4 |
+
|
5 |
+
import soundfile as sf
|
6 |
+
import tqdm
|
7 |
+
from cached_path import cached_path
|
8 |
+
|
9 |
+
from f5_tts.infer.utils_infer import (
|
10 |
+
hop_length,
|
11 |
+
infer_process,
|
12 |
+
load_model,
|
13 |
+
load_vocoder,
|
14 |
+
preprocess_ref_audio_text,
|
15 |
+
remove_silence_for_generated_wav,
|
16 |
+
save_spectrogram,
|
17 |
+
transcribe,
|
18 |
+
target_sample_rate,
|
19 |
+
)
|
20 |
+
from f5_tts.model import DiT, UNetT
|
21 |
+
from f5_tts.model.utils import seed_everything
|
22 |
+
|
23 |
+
|
24 |
+
class F5TTS:
|
25 |
+
def __init__(
|
26 |
+
self,
|
27 |
+
model_type="F5-TTS",
|
28 |
+
ckpt_file="",
|
29 |
+
vocab_file="",
|
30 |
+
ode_method="euler",
|
31 |
+
use_ema=True,
|
32 |
+
vocoder_name="vocos",
|
33 |
+
local_path=None,
|
34 |
+
device=None,
|
35 |
+
hf_cache_dir=None,
|
36 |
+
):
|
37 |
+
# Initialize parameters
|
38 |
+
self.final_wave = None
|
39 |
+
self.target_sample_rate = target_sample_rate
|
40 |
+
self.hop_length = hop_length
|
41 |
+
self.seed = -1
|
42 |
+
self.mel_spec_type = vocoder_name
|
43 |
+
|
44 |
+
# Set device
|
45 |
+
if device is not None:
|
46 |
+
self.device = device
|
47 |
+
else:
|
48 |
+
import torch
|
49 |
+
|
50 |
+
self.device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
|
51 |
+
|
52 |
+
# Load models
|
53 |
+
self.load_vocoder_model(vocoder_name, local_path=local_path, hf_cache_dir=hf_cache_dir)
|
54 |
+
self.load_ema_model(
|
55 |
+
model_type, ckpt_file, vocoder_name, vocab_file, ode_method, use_ema, hf_cache_dir=hf_cache_dir
|
56 |
+
)
|
57 |
+
|
58 |
+
def load_vocoder_model(self, vocoder_name, local_path=None, hf_cache_dir=None):
|
59 |
+
self.vocoder = load_vocoder(vocoder_name, local_path is not None, local_path, self.device, hf_cache_dir)
|
60 |
+
|
61 |
+
def load_ema_model(self, model_type, ckpt_file, mel_spec_type, vocab_file, ode_method, use_ema, hf_cache_dir=None):
|
62 |
+
if model_type == "F5-TTS":
|
63 |
+
if not ckpt_file:
|
64 |
+
if mel_spec_type == "vocos":
|
65 |
+
ckpt_file = str(
|
66 |
+
cached_path("hf://SWivid/F5-TTS/F5TTS_Base/model_1200000.safetensors", cache_dir=hf_cache_dir)
|
67 |
+
)
|
68 |
+
elif mel_spec_type == "bigvgan":
|
69 |
+
ckpt_file = str(
|
70 |
+
cached_path("hf://SWivid/F5-TTS/F5TTS_Base_bigvgan/model_1250000.pt", cache_dir=hf_cache_dir)
|
71 |
+
)
|
72 |
+
model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
73 |
+
model_cls = DiT
|
74 |
+
elif model_type == "E2-TTS":
|
75 |
+
if not ckpt_file:
|
76 |
+
ckpt_file = str(
|
77 |
+
cached_path("hf://SWivid/E2-TTS/E2TTS_Base/model_1200000.safetensors", cache_dir=hf_cache_dir)
|
78 |
+
)
|
79 |
+
model_cfg = dict(dim=1024, depth=24, heads=16, ff_mult=4)
|
80 |
+
model_cls = UNetT
|
81 |
+
else:
|
82 |
+
raise ValueError(f"Unknown model type: {model_type}")
|
83 |
+
|
84 |
+
self.ema_model = load_model(
|
85 |
+
model_cls, model_cfg, ckpt_file, mel_spec_type, vocab_file, ode_method, use_ema, self.device
|
86 |
+
)
|
87 |
+
|
88 |
+
def transcribe(self, ref_audio, language=None):
|
89 |
+
return transcribe(ref_audio, language)
|
90 |
+
|
91 |
+
def export_wav(self, wav, file_wave, remove_silence=False):
|
92 |
+
sf.write(file_wave, wav, self.target_sample_rate)
|
93 |
+
|
94 |
+
if remove_silence:
|
95 |
+
remove_silence_for_generated_wav(file_wave)
|
96 |
+
|
97 |
+
def export_spectrogram(self, spect, file_spect):
|
98 |
+
save_spectrogram(spect, file_spect)
|
99 |
+
|
100 |
+
def infer(
|
101 |
+
self,
|
102 |
+
ref_file,
|
103 |
+
ref_text,
|
104 |
+
gen_text,
|
105 |
+
show_info=print,
|
106 |
+
progress=tqdm,
|
107 |
+
target_rms=0.1,
|
108 |
+
cross_fade_duration=0.15,
|
109 |
+
sway_sampling_coef=-1,
|
110 |
+
cfg_strength=2,
|
111 |
+
nfe_step=32,
|
112 |
+
speed=1.0,
|
113 |
+
fix_duration=None,
|
114 |
+
remove_silence=False,
|
115 |
+
file_wave=None,
|
116 |
+
file_spect=None,
|
117 |
+
seed=-1,
|
118 |
+
):
|
119 |
+
if seed == -1:
|
120 |
+
seed = random.randint(0, sys.maxsize)
|
121 |
+
seed_everything(seed)
|
122 |
+
self.seed = seed
|
123 |
+
|
124 |
+
ref_file, ref_text = preprocess_ref_audio_text(ref_file, ref_text, device=self.device)
|
125 |
+
|
126 |
+
wav, sr, spect = infer_process(
|
127 |
+
ref_file,
|
128 |
+
ref_text,
|
129 |
+
gen_text,
|
130 |
+
self.ema_model,
|
131 |
+
self.vocoder,
|
132 |
+
self.mel_spec_type,
|
133 |
+
show_info=show_info,
|
134 |
+
progress=progress,
|
135 |
+
target_rms=target_rms,
|
136 |
+
cross_fade_duration=cross_fade_duration,
|
137 |
+
nfe_step=nfe_step,
|
138 |
+
cfg_strength=cfg_strength,
|
139 |
+
sway_sampling_coef=sway_sampling_coef,
|
140 |
+
speed=speed,
|
141 |
+
fix_duration=fix_duration,
|
142 |
+
device=self.device,
|
143 |
+
)
|
144 |
+
|
145 |
+
if file_wave is not None:
|
146 |
+
self.export_wav(wav, file_wave, remove_silence)
|
147 |
+
|
148 |
+
if file_spect is not None:
|
149 |
+
self.export_spectrogram(spect, file_spect)
|
150 |
+
|
151 |
+
return wav, sr, spect
|
152 |
+
|
153 |
+
|
154 |
+
if __name__ == "__main__":
|
155 |
+
f5tts = F5TTS()
|
156 |
+
|
157 |
+
wav, sr, spect = f5tts.infer(
|
158 |
+
ref_file=str(files("f5_tts").joinpath("infer/examples/basic/basic_ref_en.wav")),
|
159 |
+
ref_text="some call me nature, others call me mother nature.",
|
160 |
+
gen_text="""I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring. Respect me and I'll nurture you; ignore me and you shall face the consequences.""",
|
161 |
+
file_wave=str(files("f5_tts").joinpath("../../tests/api_out.wav")),
|
162 |
+
file_spect=str(files("f5_tts").joinpath("../../tests/api_out.png")),
|
163 |
+
seed=-1, # random seed = -1
|
164 |
+
)
|
165 |
+
|
166 |
+
print("seed :", f5tts.seed)
|
f5_tts/configs/E2TTS_Base_train.yaml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
hydra:
|
2 |
+
run:
|
3 |
+
dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
4 |
+
|
5 |
+
datasets:
|
6 |
+
name: Emilia_ZH_EN # dataset name
|
7 |
+
batch_size_per_gpu: 38400 # 8 GPUs, 8 * 38400 = 307200
|
8 |
+
batch_size_type: frame # "frame" or "sample"
|
9 |
+
max_samples: 64 # max sequences per batch if use frame-wise batch_size. we set 32 for small models, 64 for base models
|
10 |
+
num_workers: 16
|
11 |
+
|
12 |
+
optim:
|
13 |
+
epochs: 15
|
14 |
+
learning_rate: 7.5e-5
|
15 |
+
num_warmup_updates: 20000 # warmup steps
|
16 |
+
grad_accumulation_steps: 1 # note: updates = steps / grad_accumulation_steps
|
17 |
+
max_grad_norm: 1.0 # gradient clipping
|
18 |
+
bnb_optimizer: False # use bnb 8bit AdamW optimizer or not
|
19 |
+
|
20 |
+
model:
|
21 |
+
name: E2TTS_Base
|
22 |
+
tokenizer: pinyin
|
23 |
+
tokenizer_path: None # if tokenizer = 'custom', define the path to the tokenizer you want to use (should be vocab.txt)
|
24 |
+
arch:
|
25 |
+
dim: 1024
|
26 |
+
depth: 24
|
27 |
+
heads: 16
|
28 |
+
ff_mult: 4
|
29 |
+
mel_spec:
|
30 |
+
target_sample_rate: 24000
|
31 |
+
n_mel_channels: 100
|
32 |
+
hop_length: 256
|
33 |
+
win_length: 1024
|
34 |
+
n_fft: 1024
|
35 |
+
mel_spec_type: vocos # 'vocos' or 'bigvgan'
|
36 |
+
vocoder:
|
37 |
+
is_local: False # use local offline ckpt or not
|
38 |
+
local_path: None # local vocoder path
|
39 |
+
|
40 |
+
ckpts:
|
41 |
+
logger: wandb # wandb | tensorboard | None
|
42 |
+
save_per_updates: 50000 # save checkpoint per steps
|
43 |
+
last_per_steps: 5000 # save last checkpoint per steps
|
44 |
+
save_dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}
|
f5_tts/configs/E2TTS_Small_train.yaml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
hydra:
|
2 |
+
run:
|
3 |
+
dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
4 |
+
|
5 |
+
datasets:
|
6 |
+
name: Emilia_ZH_EN
|
7 |
+
batch_size_per_gpu: 38400 # 8 GPUs, 8 * 38400 = 307200
|
8 |
+
batch_size_type: frame # "frame" or "sample"
|
9 |
+
max_samples: 64 # max sequences per batch if use frame-wise batch_size. we set 32 for small models, 64 for base models
|
10 |
+
num_workers: 16
|
11 |
+
|
12 |
+
optim:
|
13 |
+
epochs: 15
|
14 |
+
learning_rate: 7.5e-5
|
15 |
+
num_warmup_updates: 20000 # warmup steps
|
16 |
+
grad_accumulation_steps: 1 # note: updates = steps / grad_accumulation_steps
|
17 |
+
max_grad_norm: 1.0
|
18 |
+
bnb_optimizer: False
|
19 |
+
|
20 |
+
model:
|
21 |
+
name: E2TTS_Small
|
22 |
+
tokenizer: pinyin
|
23 |
+
tokenizer_path: None # if tokenizer = 'custom', define the path to the tokenizer you want to use (should be vocab.txt)
|
24 |
+
arch:
|
25 |
+
dim: 768
|
26 |
+
depth: 20
|
27 |
+
heads: 12
|
28 |
+
ff_mult: 4
|
29 |
+
mel_spec:
|
30 |
+
target_sample_rate: 24000
|
31 |
+
n_mel_channels: 100
|
32 |
+
hop_length: 256
|
33 |
+
win_length: 1024
|
34 |
+
n_fft: 1024
|
35 |
+
mel_spec_type: vocos # 'vocos' or 'bigvgan'
|
36 |
+
vocoder:
|
37 |
+
is_local: False # use local offline ckpt or not
|
38 |
+
local_path: None # local vocoder path
|
39 |
+
|
40 |
+
ckpts:
|
41 |
+
logger: wandb # wandb | tensorboard | None
|
42 |
+
save_per_updates: 50000 # save checkpoint per steps
|
43 |
+
last_per_steps: 5000 # save last checkpoint per steps
|
44 |
+
save_dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}
|
f5_tts/configs/F5TTS_Base_train.yaml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
hydra:
|
2 |
+
run:
|
3 |
+
dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
4 |
+
|
5 |
+
datasets:
|
6 |
+
name: Emilia_ZH_EN # dataset name
|
7 |
+
batch_size_per_gpu: 38400 # 8 GPUs, 8 * 38400 = 307200
|
8 |
+
batch_size_type: frame # "frame" or "sample"
|
9 |
+
max_samples: 64 # max sequences per batch if use frame-wise batch_size. we set 32 for small models, 64 for base models
|
10 |
+
num_workers: 16
|
11 |
+
|
12 |
+
optim:
|
13 |
+
epochs: 15
|
14 |
+
learning_rate: 7.5e-5
|
15 |
+
num_warmup_updates: 20000 # warmup steps
|
16 |
+
grad_accumulation_steps: 1 # note: updates = steps / grad_accumulation_steps
|
17 |
+
max_grad_norm: 1.0 # gradient clipping
|
18 |
+
bnb_optimizer: False # use bnb 8bit AdamW optimizer or not
|
19 |
+
|
20 |
+
model:
|
21 |
+
name: F5TTS_Base # model name
|
22 |
+
tokenizer: pinyin # tokenizer type
|
23 |
+
tokenizer_path: None # if tokenizer = 'custom', define the path to the tokenizer you want to use (should be vocab.txt)
|
24 |
+
arch:
|
25 |
+
dim: 1024
|
26 |
+
depth: 22
|
27 |
+
heads: 16
|
28 |
+
ff_mult: 2
|
29 |
+
text_dim: 512
|
30 |
+
conv_layers: 4
|
31 |
+
mel_spec:
|
32 |
+
target_sample_rate: 24000
|
33 |
+
n_mel_channels: 100
|
34 |
+
hop_length: 256
|
35 |
+
win_length: 1024
|
36 |
+
n_fft: 1024
|
37 |
+
mel_spec_type: vocos # 'vocos' or 'bigvgan'
|
38 |
+
vocoder:
|
39 |
+
is_local: False # use local offline ckpt or not
|
40 |
+
local_path: None # local vocoder path
|
41 |
+
|
42 |
+
ckpts:
|
43 |
+
logger: wandb # wandb | tensorboard | None
|
44 |
+
save_per_updates: 50000 # save checkpoint per steps
|
45 |
+
last_per_steps: 5000 # save last checkpoint per steps
|
46 |
+
save_dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}
|
f5_tts/configs/F5TTS_Small_train.yaml
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
hydra:
|
2 |
+
run:
|
3 |
+
dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
4 |
+
|
5 |
+
datasets:
|
6 |
+
name: Emilia_ZH_EN
|
7 |
+
batch_size_per_gpu: 38400 # 8 GPUs, 8 * 38400 = 307200
|
8 |
+
batch_size_type: frame # "frame" or "sample"
|
9 |
+
max_samples: 64 # max sequences per batch if use frame-wise batch_size. we set 32 for small models, 64 for base models
|
10 |
+
num_workers: 16
|
11 |
+
|
12 |
+
optim:
|
13 |
+
epochs: 15
|
14 |
+
learning_rate: 7.5e-5
|
15 |
+
num_warmup_updates: 20000 # warmup steps
|
16 |
+
grad_accumulation_steps: 1 # note: updates = steps / grad_accumulation_steps
|
17 |
+
max_grad_norm: 1.0 # gradient clipping
|
18 |
+
bnb_optimizer: False # use bnb 8bit AdamW optimizer or not
|
19 |
+
|
20 |
+
model:
|
21 |
+
name: F5TTS_Small
|
22 |
+
tokenizer: pinyin
|
23 |
+
tokenizer_path: None # if tokenizer = 'custom', define the path to the tokenizer you want to use (should be vocab.txt)
|
24 |
+
arch:
|
25 |
+
dim: 768
|
26 |
+
depth: 18
|
27 |
+
heads: 12
|
28 |
+
ff_mult: 2
|
29 |
+
text_dim: 512
|
30 |
+
conv_layers: 4
|
31 |
+
mel_spec:
|
32 |
+
target_sample_rate: 24000
|
33 |
+
n_mel_channels: 100
|
34 |
+
hop_length: 256
|
35 |
+
win_length: 1024
|
36 |
+
n_fft: 1024
|
37 |
+
mel_spec_type: vocos # 'vocos' or 'bigvgan'
|
38 |
+
vocoder:
|
39 |
+
is_local: False # use local offline ckpt or not
|
40 |
+
local_path: None # local vocoder path
|
41 |
+
|
42 |
+
ckpts:
|
43 |
+
logger: wandb # wandb | tensorboard | None
|
44 |
+
save_per_updates: 50000 # save checkpoint per steps
|
45 |
+
last_per_steps: 5000 # save last checkpoint per steps
|
46 |
+
save_dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}
|
f5_tts/eval/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# Evaluation
|
3 |
+
|
4 |
+
Install packages for evaluation:
|
5 |
+
|
6 |
+
```bash
|
7 |
+
pip install -e .[eval]
|
8 |
+
```
|
9 |
+
|
10 |
+
## Generating Samples for Evaluation
|
11 |
+
|
12 |
+
### Prepare Test Datasets
|
13 |
+
|
14 |
+
1. *Seed-TTS testset*: Download from [seed-tts-eval](https://github.com/BytedanceSpeech/seed-tts-eval).
|
15 |
+
2. *LibriSpeech test-clean*: Download from [OpenSLR](http://www.openslr.org/12/).
|
16 |
+
3. Unzip the downloaded datasets and place them in the `data/` directory.
|
17 |
+
4. Update the path for *LibriSpeech test-clean* data in `src/f5_tts/eval/eval_infer_batch.py`
|
18 |
+
5. Our filtered LibriSpeech-PC 4-10s subset: `data/librispeech_pc_test_clean_cross_sentence.lst`
|
19 |
+
|
20 |
+
### Batch Inference for Test Set
|
21 |
+
|
22 |
+
To run batch inference for evaluations, execute the following commands:
|
23 |
+
|
24 |
+
```bash
|
25 |
+
# batch inference for evaluations
|
26 |
+
accelerate config # if not set before
|
27 |
+
bash src/f5_tts/eval/eval_infer_batch.sh
|
28 |
+
```
|
29 |
+
|
30 |
+
## Objective Evaluation on Generated Results
|
31 |
+
|
32 |
+
### Download Evaluation Model Checkpoints
|
33 |
+
|
34 |
+
1. Chinese ASR Model: [Paraformer-zh](https://huggingface.co/funasr/paraformer-zh)
|
35 |
+
2. English ASR Model: [Faster-Whisper](https://huggingface.co/Systran/faster-whisper-large-v3)
|
36 |
+
3. WavLM Model: Download from [Google Drive](https://drive.google.com/file/d/1-aE1NfzpRCLxA4GUxX9ITI3F9LlbtEGP/view).
|
37 |
+
|
38 |
+
Then update in the following scripts with the paths you put evaluation model ckpts to.
|
39 |
+
|
40 |
+
### Objective Evaluation
|
41 |
+
|
42 |
+
Update the path with your batch-inferenced results, and carry out WER / SIM evaluations:
|
43 |
+
```bash
|
44 |
+
# Evaluation for Seed-TTS test set
|
45 |
+
python src/f5_tts/eval/eval_seedtts_testset.py --gen_wav_dir <GEN_WAVE_DIR>
|
46 |
+
|
47 |
+
# Evaluation for LibriSpeech-PC test-clean (cross-sentence)
|
48 |
+
python src/f5_tts/eval/eval_librispeech_test_clean.py --gen_wav_dir <GEN_WAVE_DIR> --librispeech_test_clean_path <TEST_CLEAN_PATH>
|
49 |
+
```
|
f5_tts/eval/ecapa_tdnn.py
ADDED
@@ -0,0 +1,330 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# just for speaker similarity evaluation, third-party code
|
2 |
+
|
3 |
+
# From https://github.com/microsoft/UniSpeech/blob/main/downstreams/speaker_verification/models/
|
4 |
+
# part of the code is borrowed from https://github.com/lawlict/ECAPA-TDNN
|
5 |
+
|
6 |
+
import os
|
7 |
+
import torch
|
8 |
+
import torch.nn as nn
|
9 |
+
import torch.nn.functional as F
|
10 |
+
|
11 |
+
|
12 |
+
""" Res2Conv1d + BatchNorm1d + ReLU
|
13 |
+
"""
|
14 |
+
|
15 |
+
|
16 |
+
class Res2Conv1dReluBn(nn.Module):
|
17 |
+
"""
|
18 |
+
in_channels == out_channels == channels
|
19 |
+
"""
|
20 |
+
|
21 |
+
def __init__(self, channels, kernel_size=1, stride=1, padding=0, dilation=1, bias=True, scale=4):
|
22 |
+
super().__init__()
|
23 |
+
assert channels % scale == 0, "{} % {} != 0".format(channels, scale)
|
24 |
+
self.scale = scale
|
25 |
+
self.width = channels // scale
|
26 |
+
self.nums = scale if scale == 1 else scale - 1
|
27 |
+
|
28 |
+
self.convs = []
|
29 |
+
self.bns = []
|
30 |
+
for i in range(self.nums):
|
31 |
+
self.convs.append(nn.Conv1d(self.width, self.width, kernel_size, stride, padding, dilation, bias=bias))
|
32 |
+
self.bns.append(nn.BatchNorm1d(self.width))
|
33 |
+
self.convs = nn.ModuleList(self.convs)
|
34 |
+
self.bns = nn.ModuleList(self.bns)
|
35 |
+
|
36 |
+
def forward(self, x):
|
37 |
+
out = []
|
38 |
+
spx = torch.split(x, self.width, 1)
|
39 |
+
for i in range(self.nums):
|
40 |
+
if i == 0:
|
41 |
+
sp = spx[i]
|
42 |
+
else:
|
43 |
+
sp = sp + spx[i]
|
44 |
+
# Order: conv -> relu -> bn
|
45 |
+
sp = self.convs[i](sp)
|
46 |
+
sp = self.bns[i](F.relu(sp))
|
47 |
+
out.append(sp)
|
48 |
+
if self.scale != 1:
|
49 |
+
out.append(spx[self.nums])
|
50 |
+
out = torch.cat(out, dim=1)
|
51 |
+
|
52 |
+
return out
|
53 |
+
|
54 |
+
|
55 |
+
""" Conv1d + BatchNorm1d + ReLU
|
56 |
+
"""
|
57 |
+
|
58 |
+
|
59 |
+
class Conv1dReluBn(nn.Module):
|
60 |
+
def __init__(self, in_channels, out_channels, kernel_size=1, stride=1, padding=0, dilation=1, bias=True):
|
61 |
+
super().__init__()
|
62 |
+
self.conv = nn.Conv1d(in_channels, out_channels, kernel_size, stride, padding, dilation, bias=bias)
|
63 |
+
self.bn = nn.BatchNorm1d(out_channels)
|
64 |
+
|
65 |
+
def forward(self, x):
|
66 |
+
return self.bn(F.relu(self.conv(x)))
|
67 |
+
|
68 |
+
|
69 |
+
""" The SE connection of 1D case.
|
70 |
+
"""
|
71 |
+
|
72 |
+
|
73 |
+
class SE_Connect(nn.Module):
|
74 |
+
def __init__(self, channels, se_bottleneck_dim=128):
|
75 |
+
super().__init__()
|
76 |
+
self.linear1 = nn.Linear(channels, se_bottleneck_dim)
|
77 |
+
self.linear2 = nn.Linear(se_bottleneck_dim, channels)
|
78 |
+
|
79 |
+
def forward(self, x):
|
80 |
+
out = x.mean(dim=2)
|
81 |
+
out = F.relu(self.linear1(out))
|
82 |
+
out = torch.sigmoid(self.linear2(out))
|
83 |
+
out = x * out.unsqueeze(2)
|
84 |
+
|
85 |
+
return out
|
86 |
+
|
87 |
+
|
88 |
+
""" SE-Res2Block of the ECAPA-TDNN architecture.
|
89 |
+
"""
|
90 |
+
|
91 |
+
# def SE_Res2Block(channels, kernel_size, stride, padding, dilation, scale):
|
92 |
+
# return nn.Sequential(
|
93 |
+
# Conv1dReluBn(channels, 512, kernel_size=1, stride=1, padding=0),
|
94 |
+
# Res2Conv1dReluBn(512, kernel_size, stride, padding, dilation, scale=scale),
|
95 |
+
# Conv1dReluBn(512, channels, kernel_size=1, stride=1, padding=0),
|
96 |
+
# SE_Connect(channels)
|
97 |
+
# )
|
98 |
+
|
99 |
+
|
100 |
+
class SE_Res2Block(nn.Module):
|
101 |
+
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, dilation, scale, se_bottleneck_dim):
|
102 |
+
super().__init__()
|
103 |
+
self.Conv1dReluBn1 = Conv1dReluBn(in_channels, out_channels, kernel_size=1, stride=1, padding=0)
|
104 |
+
self.Res2Conv1dReluBn = Res2Conv1dReluBn(out_channels, kernel_size, stride, padding, dilation, scale=scale)
|
105 |
+
self.Conv1dReluBn2 = Conv1dReluBn(out_channels, out_channels, kernel_size=1, stride=1, padding=0)
|
106 |
+
self.SE_Connect = SE_Connect(out_channels, se_bottleneck_dim)
|
107 |
+
|
108 |
+
self.shortcut = None
|
109 |
+
if in_channels != out_channels:
|
110 |
+
self.shortcut = nn.Conv1d(
|
111 |
+
in_channels=in_channels,
|
112 |
+
out_channels=out_channels,
|
113 |
+
kernel_size=1,
|
114 |
+
)
|
115 |
+
|
116 |
+
def forward(self, x):
|
117 |
+
residual = x
|
118 |
+
if self.shortcut:
|
119 |
+
residual = self.shortcut(x)
|
120 |
+
|
121 |
+
x = self.Conv1dReluBn1(x)
|
122 |
+
x = self.Res2Conv1dReluBn(x)
|
123 |
+
x = self.Conv1dReluBn2(x)
|
124 |
+
x = self.SE_Connect(x)
|
125 |
+
|
126 |
+
return x + residual
|
127 |
+
|
128 |
+
|
129 |
+
""" Attentive weighted mean and standard deviation pooling.
|
130 |
+
"""
|
131 |
+
|
132 |
+
|
133 |
+
class AttentiveStatsPool(nn.Module):
|
134 |
+
def __init__(self, in_dim, attention_channels=128, global_context_att=False):
|
135 |
+
super().__init__()
|
136 |
+
self.global_context_att = global_context_att
|
137 |
+
|
138 |
+
# Use Conv1d with stride == 1 rather than Linear, then we don't need to transpose inputs.
|
139 |
+
if global_context_att:
|
140 |
+
self.linear1 = nn.Conv1d(in_dim * 3, attention_channels, kernel_size=1) # equals W and b in the paper
|
141 |
+
else:
|
142 |
+
self.linear1 = nn.Conv1d(in_dim, attention_channels, kernel_size=1) # equals W and b in the paper
|
143 |
+
self.linear2 = nn.Conv1d(attention_channels, in_dim, kernel_size=1) # equals V and k in the paper
|
144 |
+
|
145 |
+
def forward(self, x):
|
146 |
+
if self.global_context_att:
|
147 |
+
context_mean = torch.mean(x, dim=-1, keepdim=True).expand_as(x)
|
148 |
+
context_std = torch.sqrt(torch.var(x, dim=-1, keepdim=True) + 1e-10).expand_as(x)
|
149 |
+
x_in = torch.cat((x, context_mean, context_std), dim=1)
|
150 |
+
else:
|
151 |
+
x_in = x
|
152 |
+
|
153 |
+
# DON'T use ReLU here! In experiments, I find ReLU hard to converge.
|
154 |
+
alpha = torch.tanh(self.linear1(x_in))
|
155 |
+
# alpha = F.relu(self.linear1(x_in))
|
156 |
+
alpha = torch.softmax(self.linear2(alpha), dim=2)
|
157 |
+
mean = torch.sum(alpha * x, dim=2)
|
158 |
+
residuals = torch.sum(alpha * (x**2), dim=2) - mean**2
|
159 |
+
std = torch.sqrt(residuals.clamp(min=1e-9))
|
160 |
+
return torch.cat([mean, std], dim=1)
|
161 |
+
|
162 |
+
|
163 |
+
class ECAPA_TDNN(nn.Module):
|
164 |
+
def __init__(
|
165 |
+
self,
|
166 |
+
feat_dim=80,
|
167 |
+
channels=512,
|
168 |
+
emb_dim=192,
|
169 |
+
global_context_att=False,
|
170 |
+
feat_type="wavlm_large",
|
171 |
+
sr=16000,
|
172 |
+
feature_selection="hidden_states",
|
173 |
+
update_extract=False,
|
174 |
+
config_path=None,
|
175 |
+
):
|
176 |
+
super().__init__()
|
177 |
+
|
178 |
+
self.feat_type = feat_type
|
179 |
+
self.feature_selection = feature_selection
|
180 |
+
self.update_extract = update_extract
|
181 |
+
self.sr = sr
|
182 |
+
|
183 |
+
torch.hub._validate_not_a_forked_repo = lambda a, b, c: True
|
184 |
+
try:
|
185 |
+
local_s3prl_path = os.path.expanduser("~/.cache/torch/hub/s3prl_s3prl_main")
|
186 |
+
self.feature_extract = torch.hub.load(local_s3prl_path, feat_type, source="local", config_path=config_path)
|
187 |
+
except: # noqa: E722
|
188 |
+
self.feature_extract = torch.hub.load("s3prl/s3prl", feat_type)
|
189 |
+
|
190 |
+
if len(self.feature_extract.model.encoder.layers) == 24 and hasattr(
|
191 |
+
self.feature_extract.model.encoder.layers[23].self_attn, "fp32_attention"
|
192 |
+
):
|
193 |
+
self.feature_extract.model.encoder.layers[23].self_attn.fp32_attention = False
|
194 |
+
if len(self.feature_extract.model.encoder.layers) == 24 and hasattr(
|
195 |
+
self.feature_extract.model.encoder.layers[11].self_attn, "fp32_attention"
|
196 |
+
):
|
197 |
+
self.feature_extract.model.encoder.layers[11].self_attn.fp32_attention = False
|
198 |
+
|
199 |
+
self.feat_num = self.get_feat_num()
|
200 |
+
self.feature_weight = nn.Parameter(torch.zeros(self.feat_num))
|
201 |
+
|
202 |
+
if feat_type != "fbank" and feat_type != "mfcc":
|
203 |
+
freeze_list = ["final_proj", "label_embs_concat", "mask_emb", "project_q", "quantizer"]
|
204 |
+
for name, param in self.feature_extract.named_parameters():
|
205 |
+
for freeze_val in freeze_list:
|
206 |
+
if freeze_val in name:
|
207 |
+
param.requires_grad = False
|
208 |
+
break
|
209 |
+
|
210 |
+
if not self.update_extract:
|
211 |
+
for param in self.feature_extract.parameters():
|
212 |
+
param.requires_grad = False
|
213 |
+
|
214 |
+
self.instance_norm = nn.InstanceNorm1d(feat_dim)
|
215 |
+
# self.channels = [channels] * 4 + [channels * 3]
|
216 |
+
self.channels = [channels] * 4 + [1536]
|
217 |
+
|
218 |
+
self.layer1 = Conv1dReluBn(feat_dim, self.channels[0], kernel_size=5, padding=2)
|
219 |
+
self.layer2 = SE_Res2Block(
|
220 |
+
self.channels[0],
|
221 |
+
self.channels[1],
|
222 |
+
kernel_size=3,
|
223 |
+
stride=1,
|
224 |
+
padding=2,
|
225 |
+
dilation=2,
|
226 |
+
scale=8,
|
227 |
+
se_bottleneck_dim=128,
|
228 |
+
)
|
229 |
+
self.layer3 = SE_Res2Block(
|
230 |
+
self.channels[1],
|
231 |
+
self.channels[2],
|
232 |
+
kernel_size=3,
|
233 |
+
stride=1,
|
234 |
+
padding=3,
|
235 |
+
dilation=3,
|
236 |
+
scale=8,
|
237 |
+
se_bottleneck_dim=128,
|
238 |
+
)
|
239 |
+
self.layer4 = SE_Res2Block(
|
240 |
+
self.channels[2],
|
241 |
+
self.channels[3],
|
242 |
+
kernel_size=3,
|
243 |
+
stride=1,
|
244 |
+
padding=4,
|
245 |
+
dilation=4,
|
246 |
+
scale=8,
|
247 |
+
se_bottleneck_dim=128,
|
248 |
+
)
|
249 |
+
|
250 |
+
# self.conv = nn.Conv1d(self.channels[-1], self.channels[-1], kernel_size=1)
|
251 |
+
cat_channels = channels * 3
|
252 |
+
self.conv = nn.Conv1d(cat_channels, self.channels[-1], kernel_size=1)
|
253 |
+
self.pooling = AttentiveStatsPool(
|
254 |
+
self.channels[-1], attention_channels=128, global_context_att=global_context_att
|
255 |
+
)
|
256 |
+
self.bn = nn.BatchNorm1d(self.channels[-1] * 2)
|
257 |
+
self.linear = nn.Linear(self.channels[-1] * 2, emb_dim)
|
258 |
+
|
259 |
+
def get_feat_num(self):
|
260 |
+
self.feature_extract.eval()
|
261 |
+
wav = [torch.randn(self.sr).to(next(self.feature_extract.parameters()).device)]
|
262 |
+
with torch.no_grad():
|
263 |
+
features = self.feature_extract(wav)
|
264 |
+
select_feature = features[self.feature_selection]
|
265 |
+
if isinstance(select_feature, (list, tuple)):
|
266 |
+
return len(select_feature)
|
267 |
+
else:
|
268 |
+
return 1
|
269 |
+
|
270 |
+
def get_feat(self, x):
|
271 |
+
if self.update_extract:
|
272 |
+
x = self.feature_extract([sample for sample in x])
|
273 |
+
else:
|
274 |
+
with torch.no_grad():
|
275 |
+
if self.feat_type == "fbank" or self.feat_type == "mfcc":
|
276 |
+
x = self.feature_extract(x) + 1e-6 # B x feat_dim x time_len
|
277 |
+
else:
|
278 |
+
x = self.feature_extract([sample for sample in x])
|
279 |
+
|
280 |
+
if self.feat_type == "fbank":
|
281 |
+
x = x.log()
|
282 |
+
|
283 |
+
if self.feat_type != "fbank" and self.feat_type != "mfcc":
|
284 |
+
x = x[self.feature_selection]
|
285 |
+
if isinstance(x, (list, tuple)):
|
286 |
+
x = torch.stack(x, dim=0)
|
287 |
+
else:
|
288 |
+
x = x.unsqueeze(0)
|
289 |
+
norm_weights = F.softmax(self.feature_weight, dim=-1).unsqueeze(-1).unsqueeze(-1).unsqueeze(-1)
|
290 |
+
x = (norm_weights * x).sum(dim=0)
|
291 |
+
x = torch.transpose(x, 1, 2) + 1e-6
|
292 |
+
|
293 |
+
x = self.instance_norm(x)
|
294 |
+
return x
|
295 |
+
|
296 |
+
def forward(self, x):
|
297 |
+
x = self.get_feat(x)
|
298 |
+
|
299 |
+
out1 = self.layer1(x)
|
300 |
+
out2 = self.layer2(out1)
|
301 |
+
out3 = self.layer3(out2)
|
302 |
+
out4 = self.layer4(out3)
|
303 |
+
|
304 |
+
out = torch.cat([out2, out3, out4], dim=1)
|
305 |
+
out = F.relu(self.conv(out))
|
306 |
+
out = self.bn(self.pooling(out))
|
307 |
+
out = self.linear(out)
|
308 |
+
|
309 |
+
return out
|
310 |
+
|
311 |
+
|
312 |
+
def ECAPA_TDNN_SMALL(
|
313 |
+
feat_dim,
|
314 |
+
emb_dim=256,
|
315 |
+
feat_type="wavlm_large",
|
316 |
+
sr=16000,
|
317 |
+
feature_selection="hidden_states",
|
318 |
+
update_extract=False,
|
319 |
+
config_path=None,
|
320 |
+
):
|
321 |
+
return ECAPA_TDNN(
|
322 |
+
feat_dim=feat_dim,
|
323 |
+
channels=512,
|
324 |
+
emb_dim=emb_dim,
|
325 |
+
feat_type=feat_type,
|
326 |
+
sr=sr,
|
327 |
+
feature_selection=feature_selection,
|
328 |
+
update_extract=update_extract,
|
329 |
+
config_path=config_path,
|
330 |
+
)
|
f5_tts/eval/eval_infer_batch.py
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
|
4 |
+
sys.path.append(os.getcwd())
|
5 |
+
|
6 |
+
import argparse
|
7 |
+
import time
|
8 |
+
from importlib.resources import files
|
9 |
+
|
10 |
+
import torch
|
11 |
+
import torchaudio
|
12 |
+
from accelerate import Accelerator
|
13 |
+
from tqdm import tqdm
|
14 |
+
|
15 |
+
from f5_tts.eval.utils_eval import (
|
16 |
+
get_inference_prompt,
|
17 |
+
get_librispeech_test_clean_metainfo,
|
18 |
+
get_seedtts_testset_metainfo,
|
19 |
+
)
|
20 |
+
from f5_tts.infer.utils_infer import load_checkpoint, load_vocoder
|
21 |
+
from f5_tts.model import CFM, DiT, UNetT
|
22 |
+
from f5_tts.model.utils import get_tokenizer
|
23 |
+
|
24 |
+
accelerator = Accelerator()
|
25 |
+
device = f"cuda:{accelerator.process_index}"
|
26 |
+
|
27 |
+
|
28 |
+
# --------------------- Dataset Settings -------------------- #
|
29 |
+
|
30 |
+
target_sample_rate = 24000
|
31 |
+
n_mel_channels = 100
|
32 |
+
hop_length = 256
|
33 |
+
win_length = 1024
|
34 |
+
n_fft = 1024
|
35 |
+
target_rms = 0.1
|
36 |
+
|
37 |
+
rel_path = str(files("f5_tts").joinpath("../../"))
|
38 |
+
|
39 |
+
|
40 |
+
def main():
|
41 |
+
# ---------------------- infer setting ---------------------- #
|
42 |
+
|
43 |
+
parser = argparse.ArgumentParser(description="batch inference")
|
44 |
+
|
45 |
+
parser.add_argument("-s", "--seed", default=None, type=int)
|
46 |
+
parser.add_argument("-d", "--dataset", default="Emilia_ZH_EN")
|
47 |
+
parser.add_argument("-n", "--expname", required=True)
|
48 |
+
parser.add_argument("-c", "--ckptstep", default=1200000, type=int)
|
49 |
+
parser.add_argument("-m", "--mel_spec_type", default="vocos", type=str, choices=["bigvgan", "vocos"])
|
50 |
+
parser.add_argument("-to", "--tokenizer", default="pinyin", type=str, choices=["pinyin", "char"])
|
51 |
+
|
52 |
+
parser.add_argument("-nfe", "--nfestep", default=32, type=int)
|
53 |
+
parser.add_argument("-o", "--odemethod", default="euler")
|
54 |
+
parser.add_argument("-ss", "--swaysampling", default=-1, type=float)
|
55 |
+
|
56 |
+
parser.add_argument("-t", "--testset", required=True)
|
57 |
+
|
58 |
+
args = parser.parse_args()
|
59 |
+
|
60 |
+
seed = args.seed
|
61 |
+
dataset_name = args.dataset
|
62 |
+
exp_name = args.expname
|
63 |
+
ckpt_step = args.ckptstep
|
64 |
+
ckpt_path = rel_path + f"/ckpts/{exp_name}/model_{ckpt_step}.pt"
|
65 |
+
mel_spec_type = args.mel_spec_type
|
66 |
+
tokenizer = args.tokenizer
|
67 |
+
|
68 |
+
nfe_step = args.nfestep
|
69 |
+
ode_method = args.odemethod
|
70 |
+
sway_sampling_coef = args.swaysampling
|
71 |
+
|
72 |
+
testset = args.testset
|
73 |
+
|
74 |
+
infer_batch_size = 1 # max frames. 1 for ddp single inference (recommended)
|
75 |
+
cfg_strength = 2.0
|
76 |
+
speed = 1.0
|
77 |
+
use_truth_duration = False
|
78 |
+
no_ref_audio = False
|
79 |
+
|
80 |
+
if exp_name == "F5TTS_Base":
|
81 |
+
model_cls = DiT
|
82 |
+
model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
83 |
+
|
84 |
+
elif exp_name == "E2TTS_Base":
|
85 |
+
model_cls = UNetT
|
86 |
+
model_cfg = dict(dim=1024, depth=24, heads=16, ff_mult=4)
|
87 |
+
|
88 |
+
if testset == "ls_pc_test_clean":
|
89 |
+
metalst = rel_path + "/data/librispeech_pc_test_clean_cross_sentence.lst"
|
90 |
+
librispeech_test_clean_path = "<SOME_PATH>/LibriSpeech/test-clean" # test-clean path
|
91 |
+
metainfo = get_librispeech_test_clean_metainfo(metalst, librispeech_test_clean_path)
|
92 |
+
|
93 |
+
elif testset == "seedtts_test_zh":
|
94 |
+
metalst = rel_path + "/data/seedtts_testset/zh/meta.lst"
|
95 |
+
metainfo = get_seedtts_testset_metainfo(metalst)
|
96 |
+
|
97 |
+
elif testset == "seedtts_test_en":
|
98 |
+
metalst = rel_path + "/data/seedtts_testset/en/meta.lst"
|
99 |
+
metainfo = get_seedtts_testset_metainfo(metalst)
|
100 |
+
|
101 |
+
# path to save genereted wavs
|
102 |
+
output_dir = (
|
103 |
+
f"{rel_path}/"
|
104 |
+
f"results/{exp_name}_{ckpt_step}/{testset}/"
|
105 |
+
f"seed{seed}_{ode_method}_nfe{nfe_step}_{mel_spec_type}"
|
106 |
+
f"{f'_ss{sway_sampling_coef}' if sway_sampling_coef else ''}"
|
107 |
+
f"_cfg{cfg_strength}_speed{speed}"
|
108 |
+
f"{'_gt-dur' if use_truth_duration else ''}"
|
109 |
+
f"{'_no-ref-audio' if no_ref_audio else ''}"
|
110 |
+
)
|
111 |
+
|
112 |
+
# -------------------------------------------------#
|
113 |
+
|
114 |
+
use_ema = True
|
115 |
+
|
116 |
+
prompts_all = get_inference_prompt(
|
117 |
+
metainfo,
|
118 |
+
speed=speed,
|
119 |
+
tokenizer=tokenizer,
|
120 |
+
target_sample_rate=target_sample_rate,
|
121 |
+
n_mel_channels=n_mel_channels,
|
122 |
+
hop_length=hop_length,
|
123 |
+
mel_spec_type=mel_spec_type,
|
124 |
+
target_rms=target_rms,
|
125 |
+
use_truth_duration=use_truth_duration,
|
126 |
+
infer_batch_size=infer_batch_size,
|
127 |
+
)
|
128 |
+
|
129 |
+
# Vocoder model
|
130 |
+
local = False
|
131 |
+
if mel_spec_type == "vocos":
|
132 |
+
vocoder_local_path = "../checkpoints/charactr/vocos-mel-24khz"
|
133 |
+
elif mel_spec_type == "bigvgan":
|
134 |
+
vocoder_local_path = "../checkpoints/bigvgan_v2_24khz_100band_256x"
|
135 |
+
vocoder = load_vocoder(vocoder_name=mel_spec_type, is_local=local, local_path=vocoder_local_path)
|
136 |
+
|
137 |
+
# Tokenizer
|
138 |
+
vocab_char_map, vocab_size = get_tokenizer(dataset_name, tokenizer)
|
139 |
+
|
140 |
+
# Model
|
141 |
+
model = CFM(
|
142 |
+
transformer=model_cls(**model_cfg, text_num_embeds=vocab_size, mel_dim=n_mel_channels),
|
143 |
+
mel_spec_kwargs=dict(
|
144 |
+
n_fft=n_fft,
|
145 |
+
hop_length=hop_length,
|
146 |
+
win_length=win_length,
|
147 |
+
n_mel_channels=n_mel_channels,
|
148 |
+
target_sample_rate=target_sample_rate,
|
149 |
+
mel_spec_type=mel_spec_type,
|
150 |
+
),
|
151 |
+
odeint_kwargs=dict(
|
152 |
+
method=ode_method,
|
153 |
+
),
|
154 |
+
vocab_char_map=vocab_char_map,
|
155 |
+
).to(device)
|
156 |
+
|
157 |
+
dtype = torch.float32 if mel_spec_type == "bigvgan" else None
|
158 |
+
model = load_checkpoint(model, ckpt_path, device, dtype=dtype, use_ema=use_ema)
|
159 |
+
|
160 |
+
if not os.path.exists(output_dir) and accelerator.is_main_process:
|
161 |
+
os.makedirs(output_dir)
|
162 |
+
|
163 |
+
# start batch inference
|
164 |
+
accelerator.wait_for_everyone()
|
165 |
+
start = time.time()
|
166 |
+
|
167 |
+
with accelerator.split_between_processes(prompts_all) as prompts:
|
168 |
+
for prompt in tqdm(prompts, disable=not accelerator.is_local_main_process):
|
169 |
+
utts, ref_rms_list, ref_mels, ref_mel_lens, total_mel_lens, final_text_list = prompt
|
170 |
+
ref_mels = ref_mels.to(device)
|
171 |
+
ref_mel_lens = torch.tensor(ref_mel_lens, dtype=torch.long).to(device)
|
172 |
+
total_mel_lens = torch.tensor(total_mel_lens, dtype=torch.long).to(device)
|
173 |
+
|
174 |
+
# Inference
|
175 |
+
with torch.inference_mode():
|
176 |
+
generated, _ = model.sample(
|
177 |
+
cond=ref_mels,
|
178 |
+
text=final_text_list,
|
179 |
+
duration=total_mel_lens,
|
180 |
+
lens=ref_mel_lens,
|
181 |
+
steps=nfe_step,
|
182 |
+
cfg_strength=cfg_strength,
|
183 |
+
sway_sampling_coef=sway_sampling_coef,
|
184 |
+
no_ref_audio=no_ref_audio,
|
185 |
+
seed=seed,
|
186 |
+
)
|
187 |
+
# Final result
|
188 |
+
for i, gen in enumerate(generated):
|
189 |
+
gen = gen[ref_mel_lens[i] : total_mel_lens[i], :].unsqueeze(0)
|
190 |
+
gen_mel_spec = gen.permute(0, 2, 1).to(torch.float32)
|
191 |
+
if mel_spec_type == "vocos":
|
192 |
+
generated_wave = vocoder.decode(gen_mel_spec).cpu()
|
193 |
+
elif mel_spec_type == "bigvgan":
|
194 |
+
generated_wave = vocoder(gen_mel_spec).squeeze(0).cpu()
|
195 |
+
|
196 |
+
if ref_rms_list[i] < target_rms:
|
197 |
+
generated_wave = generated_wave * ref_rms_list[i] / target_rms
|
198 |
+
torchaudio.save(f"{output_dir}/{utts[i]}.wav", generated_wave, target_sample_rate)
|
199 |
+
|
200 |
+
accelerator.wait_for_everyone()
|
201 |
+
if accelerator.is_main_process:
|
202 |
+
timediff = time.time() - start
|
203 |
+
print(f"Done batch inference in {timediff / 60 :.2f} minutes.")
|
204 |
+
|
205 |
+
|
206 |
+
if __name__ == "__main__":
|
207 |
+
main()
|
f5_tts/eval/eval_infer_batch.sh
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# e.g. F5-TTS, 16 NFE
|
4 |
+
accelerate launch src/f5_tts/eval/eval_infer_batch.py -s 0 -n "F5TTS_Base" -t "seedtts_test_zh" -nfe 16
|
5 |
+
accelerate launch src/f5_tts/eval/eval_infer_batch.py -s 0 -n "F5TTS_Base" -t "seedtts_test_en" -nfe 16
|
6 |
+
accelerate launch src/f5_tts/eval/eval_infer_batch.py -s 0 -n "F5TTS_Base" -t "ls_pc_test_clean" -nfe 16
|
7 |
+
|
8 |
+
# e.g. Vanilla E2 TTS, 32 NFE
|
9 |
+
accelerate launch src/f5_tts/eval/eval_infer_batch.py -s 0 -n "E2TTS_Base" -t "seedtts_test_zh" -o "midpoint" -ss 0
|
10 |
+
accelerate launch src/f5_tts/eval/eval_infer_batch.py -s 0 -n "E2TTS_Base" -t "seedtts_test_en" -o "midpoint" -ss 0
|
11 |
+
accelerate launch src/f5_tts/eval/eval_infer_batch.py -s 0 -n "E2TTS_Base" -t "ls_pc_test_clean" -o "midpoint" -ss 0
|
12 |
+
|
13 |
+
# etc.
|
f5_tts/eval/eval_librispeech_test_clean.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Evaluate with Librispeech test-clean, ~3s prompt to generate 4-10s audio (the way of valle/voicebox evaluation)
|
2 |
+
|
3 |
+
import sys
|
4 |
+
import os
|
5 |
+
import argparse
|
6 |
+
|
7 |
+
sys.path.append(os.getcwd())
|
8 |
+
|
9 |
+
import multiprocessing as mp
|
10 |
+
from importlib.resources import files
|
11 |
+
|
12 |
+
import numpy as np
|
13 |
+
|
14 |
+
from f5_tts.eval.utils_eval import (
|
15 |
+
get_librispeech_test,
|
16 |
+
run_asr_wer,
|
17 |
+
run_sim,
|
18 |
+
)
|
19 |
+
|
20 |
+
rel_path = str(files("f5_tts").joinpath("../../"))
|
21 |
+
|
22 |
+
|
23 |
+
def get_args():
|
24 |
+
parser = argparse.ArgumentParser()
|
25 |
+
parser.add_argument("-e", "--eval_task", type=str, default="wer", choices=["sim", "wer"])
|
26 |
+
parser.add_argument("-l", "--lang", type=str, default="en")
|
27 |
+
parser.add_argument("-g", "--gen_wav_dir", type=str, required=True)
|
28 |
+
parser.add_argument("-p", "--librispeech_test_clean_path", type=str, required=True)
|
29 |
+
parser.add_argument("-n", "--gpu_nums", type=int, default=8, help="Number of GPUs to use")
|
30 |
+
parser.add_argument("--local", action="store_true", help="Use local custom checkpoint directory")
|
31 |
+
return parser.parse_args()
|
32 |
+
|
33 |
+
|
34 |
+
def main():
|
35 |
+
args = get_args()
|
36 |
+
eval_task = args.eval_task
|
37 |
+
lang = args.lang
|
38 |
+
librispeech_test_clean_path = args.librispeech_test_clean_path # test-clean path
|
39 |
+
gen_wav_dir = args.gen_wav_dir
|
40 |
+
metalst = rel_path + "/data/librispeech_pc_test_clean_cross_sentence.lst"
|
41 |
+
|
42 |
+
gpus = list(range(args.gpu_nums))
|
43 |
+
test_set = get_librispeech_test(metalst, gen_wav_dir, gpus, librispeech_test_clean_path)
|
44 |
+
|
45 |
+
## In LibriSpeech, some speakers utilized varying voice characteristics for different characters in the book,
|
46 |
+
## leading to a low similarity for the ground truth in some cases.
|
47 |
+
# test_set = get_librispeech_test(metalst, gen_wav_dir, gpus, librispeech_test_clean_path, eval_ground_truth = True) # eval ground truth
|
48 |
+
|
49 |
+
local = args.local
|
50 |
+
if local: # use local custom checkpoint dir
|
51 |
+
asr_ckpt_dir = "../checkpoints/Systran/faster-whisper-large-v3"
|
52 |
+
else:
|
53 |
+
asr_ckpt_dir = "" # auto download to cache dir
|
54 |
+
wavlm_ckpt_dir = "../checkpoints/UniSpeech/wavlm_large_finetune.pth"
|
55 |
+
|
56 |
+
# --------------------------- WER ---------------------------
|
57 |
+
if eval_task == "wer":
|
58 |
+
wers = []
|
59 |
+
with mp.Pool(processes=len(gpus)) as pool:
|
60 |
+
args = [(rank, lang, sub_test_set, asr_ckpt_dir) for (rank, sub_test_set) in test_set]
|
61 |
+
results = pool.map(run_asr_wer, args)
|
62 |
+
for wers_ in results:
|
63 |
+
wers.extend(wers_)
|
64 |
+
|
65 |
+
wer = round(np.mean(wers) * 100, 3)
|
66 |
+
print(f"\nTotal {len(wers)} samples")
|
67 |
+
print(f"WER : {wer}%")
|
68 |
+
|
69 |
+
# --------------------------- SIM ---------------------------
|
70 |
+
if eval_task == "sim":
|
71 |
+
sim_list = []
|
72 |
+
with mp.Pool(processes=len(gpus)) as pool:
|
73 |
+
args = [(rank, sub_test_set, wavlm_ckpt_dir) for (rank, sub_test_set) in test_set]
|
74 |
+
results = pool.map(run_sim, args)
|
75 |
+
for sim_ in results:
|
76 |
+
sim_list.extend(sim_)
|
77 |
+
|
78 |
+
sim = round(sum(sim_list) / len(sim_list), 3)
|
79 |
+
print(f"\nTotal {len(sim_list)} samples")
|
80 |
+
print(f"SIM : {sim}")
|
81 |
+
|
82 |
+
|
83 |
+
if __name__ == "__main__":
|
84 |
+
main()
|
f5_tts/eval/eval_seedtts_testset.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Evaluate with Seed-TTS testset
|
2 |
+
|
3 |
+
import sys
|
4 |
+
import os
|
5 |
+
import argparse
|
6 |
+
|
7 |
+
sys.path.append(os.getcwd())
|
8 |
+
|
9 |
+
import multiprocessing as mp
|
10 |
+
from importlib.resources import files
|
11 |
+
|
12 |
+
import numpy as np
|
13 |
+
|
14 |
+
from f5_tts.eval.utils_eval import (
|
15 |
+
get_seed_tts_test,
|
16 |
+
run_asr_wer,
|
17 |
+
run_sim,
|
18 |
+
)
|
19 |
+
|
20 |
+
rel_path = str(files("f5_tts").joinpath("../../"))
|
21 |
+
|
22 |
+
|
23 |
+
def get_args():
|
24 |
+
parser = argparse.ArgumentParser()
|
25 |
+
parser.add_argument("-e", "--eval_task", type=str, default="wer", choices=["sim", "wer"])
|
26 |
+
parser.add_argument("-l", "--lang", type=str, default="en", choices=["zh", "en"])
|
27 |
+
parser.add_argument("-g", "--gen_wav_dir", type=str, required=True)
|
28 |
+
parser.add_argument("-n", "--gpu_nums", type=int, default=8, help="Number of GPUs to use")
|
29 |
+
parser.add_argument("--local", action="store_true", help="Use local custom checkpoint directory")
|
30 |
+
return parser.parse_args()
|
31 |
+
|
32 |
+
|
33 |
+
def main():
|
34 |
+
args = get_args()
|
35 |
+
eval_task = args.eval_task
|
36 |
+
lang = args.lang
|
37 |
+
gen_wav_dir = args.gen_wav_dir
|
38 |
+
metalst = rel_path + f"/data/seedtts_testset/{lang}/meta.lst" # seed-tts testset
|
39 |
+
|
40 |
+
# NOTE. paraformer-zh result will be slightly different according to the number of gpus, cuz batchsize is different
|
41 |
+
# zh 1.254 seems a result of 4 workers wer_seed_tts
|
42 |
+
gpus = list(range(args.gpu_nums))
|
43 |
+
test_set = get_seed_tts_test(metalst, gen_wav_dir, gpus)
|
44 |
+
|
45 |
+
local = args.local
|
46 |
+
if local: # use local custom checkpoint dir
|
47 |
+
if lang == "zh":
|
48 |
+
asr_ckpt_dir = "../checkpoints/funasr" # paraformer-zh dir under funasr
|
49 |
+
elif lang == "en":
|
50 |
+
asr_ckpt_dir = "../checkpoints/Systran/faster-whisper-large-v3"
|
51 |
+
else:
|
52 |
+
asr_ckpt_dir = "" # auto download to cache dir
|
53 |
+
wavlm_ckpt_dir = "../checkpoints/UniSpeech/wavlm_large_finetune.pth"
|
54 |
+
|
55 |
+
# --------------------------- WER ---------------------------
|
56 |
+
|
57 |
+
if eval_task == "wer":
|
58 |
+
wers = []
|
59 |
+
with mp.Pool(processes=len(gpus)) as pool:
|
60 |
+
args = [(rank, lang, sub_test_set, asr_ckpt_dir) for (rank, sub_test_set) in test_set]
|
61 |
+
results = pool.map(run_asr_wer, args)
|
62 |
+
for wers_ in results:
|
63 |
+
wers.extend(wers_)
|
64 |
+
|
65 |
+
wer = round(np.mean(wers) * 100, 3)
|
66 |
+
print(f"\nTotal {len(wers)} samples")
|
67 |
+
print(f"WER : {wer}%")
|
68 |
+
|
69 |
+
# --------------------------- SIM ---------------------------
|
70 |
+
if eval_task == "sim":
|
71 |
+
sim_list = []
|
72 |
+
with mp.Pool(processes=len(gpus)) as pool:
|
73 |
+
args = [(rank, sub_test_set, wavlm_ckpt_dir) for (rank, sub_test_set) in test_set]
|
74 |
+
results = pool.map(run_sim, args)
|
75 |
+
for sim_ in results:
|
76 |
+
sim_list.extend(sim_)
|
77 |
+
|
78 |
+
sim = round(sum(sim_list) / len(sim_list), 3)
|
79 |
+
print(f"\nTotal {len(sim_list)} samples")
|
80 |
+
print(f"SIM : {sim}")
|
81 |
+
|
82 |
+
|
83 |
+
if __name__ == "__main__":
|
84 |
+
main()
|
f5_tts/eval/utils_eval.py
ADDED
@@ -0,0 +1,405 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import math
|
2 |
+
import os
|
3 |
+
import random
|
4 |
+
import string
|
5 |
+
|
6 |
+
import torch
|
7 |
+
import torch.nn.functional as F
|
8 |
+
import torchaudio
|
9 |
+
from tqdm import tqdm
|
10 |
+
|
11 |
+
from f5_tts.eval.ecapa_tdnn import ECAPA_TDNN_SMALL
|
12 |
+
from f5_tts.model.modules import MelSpec
|
13 |
+
from f5_tts.model.utils import convert_char_to_pinyin
|
14 |
+
|
15 |
+
|
16 |
+
# seedtts testset metainfo: utt, prompt_text, prompt_wav, gt_text, gt_wav
|
17 |
+
def get_seedtts_testset_metainfo(metalst):
|
18 |
+
f = open(metalst)
|
19 |
+
lines = f.readlines()
|
20 |
+
f.close()
|
21 |
+
metainfo = []
|
22 |
+
for line in lines:
|
23 |
+
if len(line.strip().split("|")) == 5:
|
24 |
+
utt, prompt_text, prompt_wav, gt_text, gt_wav = line.strip().split("|")
|
25 |
+
elif len(line.strip().split("|")) == 4:
|
26 |
+
utt, prompt_text, prompt_wav, gt_text = line.strip().split("|")
|
27 |
+
gt_wav = os.path.join(os.path.dirname(metalst), "wavs", utt + ".wav")
|
28 |
+
if not os.path.isabs(prompt_wav):
|
29 |
+
prompt_wav = os.path.join(os.path.dirname(metalst), prompt_wav)
|
30 |
+
metainfo.append((utt, prompt_text, prompt_wav, gt_text, gt_wav))
|
31 |
+
return metainfo
|
32 |
+
|
33 |
+
|
34 |
+
# librispeech test-clean metainfo: gen_utt, ref_txt, ref_wav, gen_txt, gen_wav
|
35 |
+
def get_librispeech_test_clean_metainfo(metalst, librispeech_test_clean_path):
|
36 |
+
f = open(metalst)
|
37 |
+
lines = f.readlines()
|
38 |
+
f.close()
|
39 |
+
metainfo = []
|
40 |
+
for line in lines:
|
41 |
+
ref_utt, ref_dur, ref_txt, gen_utt, gen_dur, gen_txt = line.strip().split("\t")
|
42 |
+
|
43 |
+
# ref_txt = ref_txt[0] + ref_txt[1:].lower() + '.' # if use librispeech test-clean (no-pc)
|
44 |
+
ref_spk_id, ref_chaptr_id, _ = ref_utt.split("-")
|
45 |
+
ref_wav = os.path.join(librispeech_test_clean_path, ref_spk_id, ref_chaptr_id, ref_utt + ".flac")
|
46 |
+
|
47 |
+
# gen_txt = gen_txt[0] + gen_txt[1:].lower() + '.' # if use librispeech test-clean (no-pc)
|
48 |
+
gen_spk_id, gen_chaptr_id, _ = gen_utt.split("-")
|
49 |
+
gen_wav = os.path.join(librispeech_test_clean_path, gen_spk_id, gen_chaptr_id, gen_utt + ".flac")
|
50 |
+
|
51 |
+
metainfo.append((gen_utt, ref_txt, ref_wav, " " + gen_txt, gen_wav))
|
52 |
+
|
53 |
+
return metainfo
|
54 |
+
|
55 |
+
|
56 |
+
# padded to max length mel batch
|
57 |
+
def padded_mel_batch(ref_mels):
|
58 |
+
max_mel_length = torch.LongTensor([mel.shape[-1] for mel in ref_mels]).amax()
|
59 |
+
padded_ref_mels = []
|
60 |
+
for mel in ref_mels:
|
61 |
+
padded_ref_mel = F.pad(mel, (0, max_mel_length - mel.shape[-1]), value=0)
|
62 |
+
padded_ref_mels.append(padded_ref_mel)
|
63 |
+
padded_ref_mels = torch.stack(padded_ref_mels)
|
64 |
+
padded_ref_mels = padded_ref_mels.permute(0, 2, 1)
|
65 |
+
return padded_ref_mels
|
66 |
+
|
67 |
+
|
68 |
+
# get prompts from metainfo containing: utt, prompt_text, prompt_wav, gt_text, gt_wav
|
69 |
+
|
70 |
+
|
71 |
+
def get_inference_prompt(
|
72 |
+
metainfo,
|
73 |
+
speed=1.0,
|
74 |
+
tokenizer="pinyin",
|
75 |
+
polyphone=True,
|
76 |
+
target_sample_rate=24000,
|
77 |
+
n_fft=1024,
|
78 |
+
win_length=1024,
|
79 |
+
n_mel_channels=100,
|
80 |
+
hop_length=256,
|
81 |
+
mel_spec_type="vocos",
|
82 |
+
target_rms=0.1,
|
83 |
+
use_truth_duration=False,
|
84 |
+
infer_batch_size=1,
|
85 |
+
num_buckets=200,
|
86 |
+
min_secs=3,
|
87 |
+
max_secs=40,
|
88 |
+
):
|
89 |
+
prompts_all = []
|
90 |
+
|
91 |
+
min_tokens = min_secs * target_sample_rate // hop_length
|
92 |
+
max_tokens = max_secs * target_sample_rate // hop_length
|
93 |
+
|
94 |
+
batch_accum = [0] * num_buckets
|
95 |
+
utts, ref_rms_list, ref_mels, ref_mel_lens, total_mel_lens, final_text_list = (
|
96 |
+
[[] for _ in range(num_buckets)] for _ in range(6)
|
97 |
+
)
|
98 |
+
|
99 |
+
mel_spectrogram = MelSpec(
|
100 |
+
n_fft=n_fft,
|
101 |
+
hop_length=hop_length,
|
102 |
+
win_length=win_length,
|
103 |
+
n_mel_channels=n_mel_channels,
|
104 |
+
target_sample_rate=target_sample_rate,
|
105 |
+
mel_spec_type=mel_spec_type,
|
106 |
+
)
|
107 |
+
|
108 |
+
for utt, prompt_text, prompt_wav, gt_text, gt_wav in tqdm(metainfo, desc="Processing prompts..."):
|
109 |
+
# Audio
|
110 |
+
ref_audio, ref_sr = torchaudio.load(prompt_wav)
|
111 |
+
ref_rms = torch.sqrt(torch.mean(torch.square(ref_audio)))
|
112 |
+
if ref_rms < target_rms:
|
113 |
+
ref_audio = ref_audio * target_rms / ref_rms
|
114 |
+
assert ref_audio.shape[-1] > 5000, f"Empty prompt wav: {prompt_wav}, or torchaudio backend issue."
|
115 |
+
if ref_sr != target_sample_rate:
|
116 |
+
resampler = torchaudio.transforms.Resample(ref_sr, target_sample_rate)
|
117 |
+
ref_audio = resampler(ref_audio)
|
118 |
+
|
119 |
+
# Text
|
120 |
+
if len(prompt_text[-1].encode("utf-8")) == 1:
|
121 |
+
prompt_text = prompt_text + " "
|
122 |
+
text = [prompt_text + gt_text]
|
123 |
+
if tokenizer == "pinyin":
|
124 |
+
text_list = convert_char_to_pinyin(text, polyphone=polyphone)
|
125 |
+
else:
|
126 |
+
text_list = text
|
127 |
+
|
128 |
+
# Duration, mel frame length
|
129 |
+
ref_mel_len = ref_audio.shape[-1] // hop_length
|
130 |
+
if use_truth_duration:
|
131 |
+
gt_audio, gt_sr = torchaudio.load(gt_wav)
|
132 |
+
if gt_sr != target_sample_rate:
|
133 |
+
resampler = torchaudio.transforms.Resample(gt_sr, target_sample_rate)
|
134 |
+
gt_audio = resampler(gt_audio)
|
135 |
+
total_mel_len = ref_mel_len + int(gt_audio.shape[-1] / hop_length / speed)
|
136 |
+
|
137 |
+
# # test vocoder resynthesis
|
138 |
+
# ref_audio = gt_audio
|
139 |
+
else:
|
140 |
+
ref_text_len = len(prompt_text.encode("utf-8"))
|
141 |
+
gen_text_len = len(gt_text.encode("utf-8"))
|
142 |
+
total_mel_len = ref_mel_len + int(ref_mel_len / ref_text_len * gen_text_len / speed)
|
143 |
+
|
144 |
+
# to mel spectrogram
|
145 |
+
ref_mel = mel_spectrogram(ref_audio)
|
146 |
+
ref_mel = ref_mel.squeeze(0)
|
147 |
+
|
148 |
+
# deal with batch
|
149 |
+
assert infer_batch_size > 0, "infer_batch_size should be greater than 0."
|
150 |
+
assert (
|
151 |
+
min_tokens <= total_mel_len <= max_tokens
|
152 |
+
), f"Audio {utt} has duration {total_mel_len*hop_length//target_sample_rate}s out of range [{min_secs}, {max_secs}]."
|
153 |
+
bucket_i = math.floor((total_mel_len - min_tokens) / (max_tokens - min_tokens + 1) * num_buckets)
|
154 |
+
|
155 |
+
utts[bucket_i].append(utt)
|
156 |
+
ref_rms_list[bucket_i].append(ref_rms)
|
157 |
+
ref_mels[bucket_i].append(ref_mel)
|
158 |
+
ref_mel_lens[bucket_i].append(ref_mel_len)
|
159 |
+
total_mel_lens[bucket_i].append(total_mel_len)
|
160 |
+
final_text_list[bucket_i].extend(text_list)
|
161 |
+
|
162 |
+
batch_accum[bucket_i] += total_mel_len
|
163 |
+
|
164 |
+
if batch_accum[bucket_i] >= infer_batch_size:
|
165 |
+
# print(f"\n{len(ref_mels[bucket_i][0][0])}\n{ref_mel_lens[bucket_i]}\n{total_mel_lens[bucket_i]}")
|
166 |
+
prompts_all.append(
|
167 |
+
(
|
168 |
+
utts[bucket_i],
|
169 |
+
ref_rms_list[bucket_i],
|
170 |
+
padded_mel_batch(ref_mels[bucket_i]),
|
171 |
+
ref_mel_lens[bucket_i],
|
172 |
+
total_mel_lens[bucket_i],
|
173 |
+
final_text_list[bucket_i],
|
174 |
+
)
|
175 |
+
)
|
176 |
+
batch_accum[bucket_i] = 0
|
177 |
+
(
|
178 |
+
utts[bucket_i],
|
179 |
+
ref_rms_list[bucket_i],
|
180 |
+
ref_mels[bucket_i],
|
181 |
+
ref_mel_lens[bucket_i],
|
182 |
+
total_mel_lens[bucket_i],
|
183 |
+
final_text_list[bucket_i],
|
184 |
+
) = [], [], [], [], [], []
|
185 |
+
|
186 |
+
# add residual
|
187 |
+
for bucket_i, bucket_frames in enumerate(batch_accum):
|
188 |
+
if bucket_frames > 0:
|
189 |
+
prompts_all.append(
|
190 |
+
(
|
191 |
+
utts[bucket_i],
|
192 |
+
ref_rms_list[bucket_i],
|
193 |
+
padded_mel_batch(ref_mels[bucket_i]),
|
194 |
+
ref_mel_lens[bucket_i],
|
195 |
+
total_mel_lens[bucket_i],
|
196 |
+
final_text_list[bucket_i],
|
197 |
+
)
|
198 |
+
)
|
199 |
+
# not only leave easy work for last workers
|
200 |
+
random.seed(666)
|
201 |
+
random.shuffle(prompts_all)
|
202 |
+
|
203 |
+
return prompts_all
|
204 |
+
|
205 |
+
|
206 |
+
# get wav_res_ref_text of seed-tts test metalst
|
207 |
+
# https://github.com/BytedanceSpeech/seed-tts-eval
|
208 |
+
|
209 |
+
|
210 |
+
def get_seed_tts_test(metalst, gen_wav_dir, gpus):
|
211 |
+
f = open(metalst)
|
212 |
+
lines = f.readlines()
|
213 |
+
f.close()
|
214 |
+
|
215 |
+
test_set_ = []
|
216 |
+
for line in tqdm(lines):
|
217 |
+
if len(line.strip().split("|")) == 5:
|
218 |
+
utt, prompt_text, prompt_wav, gt_text, gt_wav = line.strip().split("|")
|
219 |
+
elif len(line.strip().split("|")) == 4:
|
220 |
+
utt, prompt_text, prompt_wav, gt_text = line.strip().split("|")
|
221 |
+
|
222 |
+
if not os.path.exists(os.path.join(gen_wav_dir, utt + ".wav")):
|
223 |
+
continue
|
224 |
+
gen_wav = os.path.join(gen_wav_dir, utt + ".wav")
|
225 |
+
if not os.path.isabs(prompt_wav):
|
226 |
+
prompt_wav = os.path.join(os.path.dirname(metalst), prompt_wav)
|
227 |
+
|
228 |
+
test_set_.append((gen_wav, prompt_wav, gt_text))
|
229 |
+
|
230 |
+
num_jobs = len(gpus)
|
231 |
+
if num_jobs == 1:
|
232 |
+
return [(gpus[0], test_set_)]
|
233 |
+
|
234 |
+
wav_per_job = len(test_set_) // num_jobs + 1
|
235 |
+
test_set = []
|
236 |
+
for i in range(num_jobs):
|
237 |
+
test_set.append((gpus[i], test_set_[i * wav_per_job : (i + 1) * wav_per_job]))
|
238 |
+
|
239 |
+
return test_set
|
240 |
+
|
241 |
+
|
242 |
+
# get librispeech test-clean cross sentence test
|
243 |
+
|
244 |
+
|
245 |
+
def get_librispeech_test(metalst, gen_wav_dir, gpus, librispeech_test_clean_path, eval_ground_truth=False):
|
246 |
+
f = open(metalst)
|
247 |
+
lines = f.readlines()
|
248 |
+
f.close()
|
249 |
+
|
250 |
+
test_set_ = []
|
251 |
+
for line in tqdm(lines):
|
252 |
+
ref_utt, ref_dur, ref_txt, gen_utt, gen_dur, gen_txt = line.strip().split("\t")
|
253 |
+
|
254 |
+
if eval_ground_truth:
|
255 |
+
gen_spk_id, gen_chaptr_id, _ = gen_utt.split("-")
|
256 |
+
gen_wav = os.path.join(librispeech_test_clean_path, gen_spk_id, gen_chaptr_id, gen_utt + ".flac")
|
257 |
+
else:
|
258 |
+
if not os.path.exists(os.path.join(gen_wav_dir, gen_utt + ".wav")):
|
259 |
+
raise FileNotFoundError(f"Generated wav not found: {gen_utt}")
|
260 |
+
gen_wav = os.path.join(gen_wav_dir, gen_utt + ".wav")
|
261 |
+
|
262 |
+
ref_spk_id, ref_chaptr_id, _ = ref_utt.split("-")
|
263 |
+
ref_wav = os.path.join(librispeech_test_clean_path, ref_spk_id, ref_chaptr_id, ref_utt + ".flac")
|
264 |
+
|
265 |
+
test_set_.append((gen_wav, ref_wav, gen_txt))
|
266 |
+
|
267 |
+
num_jobs = len(gpus)
|
268 |
+
if num_jobs == 1:
|
269 |
+
return [(gpus[0], test_set_)]
|
270 |
+
|
271 |
+
wav_per_job = len(test_set_) // num_jobs + 1
|
272 |
+
test_set = []
|
273 |
+
for i in range(num_jobs):
|
274 |
+
test_set.append((gpus[i], test_set_[i * wav_per_job : (i + 1) * wav_per_job]))
|
275 |
+
|
276 |
+
return test_set
|
277 |
+
|
278 |
+
|
279 |
+
# load asr model
|
280 |
+
|
281 |
+
|
282 |
+
def load_asr_model(lang, ckpt_dir=""):
|
283 |
+
if lang == "zh":
|
284 |
+
from funasr import AutoModel
|
285 |
+
|
286 |
+
model = AutoModel(
|
287 |
+
model=os.path.join(ckpt_dir, "paraformer-zh"),
|
288 |
+
# vad_model = os.path.join(ckpt_dir, "fsmn-vad"),
|
289 |
+
# punc_model = os.path.join(ckpt_dir, "ct-punc"),
|
290 |
+
# spk_model = os.path.join(ckpt_dir, "cam++"),
|
291 |
+
disable_update=True,
|
292 |
+
) # following seed-tts setting
|
293 |
+
elif lang == "en":
|
294 |
+
from faster_whisper import WhisperModel
|
295 |
+
|
296 |
+
model_size = "large-v3" if ckpt_dir == "" else ckpt_dir
|
297 |
+
model = WhisperModel(model_size, device="cuda", compute_type="float16")
|
298 |
+
return model
|
299 |
+
|
300 |
+
|
301 |
+
# WER Evaluation, the way Seed-TTS does
|
302 |
+
|
303 |
+
|
304 |
+
def run_asr_wer(args):
|
305 |
+
rank, lang, test_set, ckpt_dir = args
|
306 |
+
|
307 |
+
if lang == "zh":
|
308 |
+
import zhconv
|
309 |
+
|
310 |
+
torch.cuda.set_device(rank)
|
311 |
+
elif lang == "en":
|
312 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = str(rank)
|
313 |
+
else:
|
314 |
+
raise NotImplementedError(
|
315 |
+
"lang support only 'zh' (funasr paraformer-zh), 'en' (faster-whisper-large-v3), for now."
|
316 |
+
)
|
317 |
+
|
318 |
+
asr_model = load_asr_model(lang, ckpt_dir=ckpt_dir)
|
319 |
+
|
320 |
+
from zhon.hanzi import punctuation
|
321 |
+
|
322 |
+
punctuation_all = punctuation + string.punctuation
|
323 |
+
wers = []
|
324 |
+
|
325 |
+
from jiwer import compute_measures
|
326 |
+
|
327 |
+
for gen_wav, prompt_wav, truth in tqdm(test_set):
|
328 |
+
if lang == "zh":
|
329 |
+
res = asr_model.generate(input=gen_wav, batch_size_s=300, disable_pbar=True)
|
330 |
+
hypo = res[0]["text"]
|
331 |
+
hypo = zhconv.convert(hypo, "zh-cn")
|
332 |
+
elif lang == "en":
|
333 |
+
segments, _ = asr_model.transcribe(gen_wav, beam_size=5, language="en")
|
334 |
+
hypo = ""
|
335 |
+
for segment in segments:
|
336 |
+
hypo = hypo + " " + segment.text
|
337 |
+
|
338 |
+
# raw_truth = truth
|
339 |
+
# raw_hypo = hypo
|
340 |
+
|
341 |
+
for x in punctuation_all:
|
342 |
+
truth = truth.replace(x, "")
|
343 |
+
hypo = hypo.replace(x, "")
|
344 |
+
|
345 |
+
truth = truth.replace(" ", " ")
|
346 |
+
hypo = hypo.replace(" ", " ")
|
347 |
+
|
348 |
+
if lang == "zh":
|
349 |
+
truth = " ".join([x for x in truth])
|
350 |
+
hypo = " ".join([x for x in hypo])
|
351 |
+
elif lang == "en":
|
352 |
+
truth = truth.lower()
|
353 |
+
hypo = hypo.lower()
|
354 |
+
|
355 |
+
measures = compute_measures(truth, hypo)
|
356 |
+
wer = measures["wer"]
|
357 |
+
|
358 |
+
# ref_list = truth.split(" ")
|
359 |
+
# subs = measures["substitutions"] / len(ref_list)
|
360 |
+
# dele = measures["deletions"] / len(ref_list)
|
361 |
+
# inse = measures["insertions"] / len(ref_list)
|
362 |
+
|
363 |
+
wers.append(wer)
|
364 |
+
|
365 |
+
return wers
|
366 |
+
|
367 |
+
|
368 |
+
# SIM Evaluation
|
369 |
+
|
370 |
+
|
371 |
+
def run_sim(args):
|
372 |
+
rank, test_set, ckpt_dir = args
|
373 |
+
device = f"cuda:{rank}"
|
374 |
+
|
375 |
+
model = ECAPA_TDNN_SMALL(feat_dim=1024, feat_type="wavlm_large", config_path=None)
|
376 |
+
state_dict = torch.load(ckpt_dir, weights_only=True, map_location=lambda storage, loc: storage)
|
377 |
+
model.load_state_dict(state_dict["model"], strict=False)
|
378 |
+
|
379 |
+
use_gpu = True if torch.cuda.is_available() else False
|
380 |
+
if use_gpu:
|
381 |
+
model = model.cuda(device)
|
382 |
+
model.eval()
|
383 |
+
|
384 |
+
sim_list = []
|
385 |
+
for wav1, wav2, truth in tqdm(test_set):
|
386 |
+
wav1, sr1 = torchaudio.load(wav1)
|
387 |
+
wav2, sr2 = torchaudio.load(wav2)
|
388 |
+
|
389 |
+
resample1 = torchaudio.transforms.Resample(orig_freq=sr1, new_freq=16000)
|
390 |
+
resample2 = torchaudio.transforms.Resample(orig_freq=sr2, new_freq=16000)
|
391 |
+
wav1 = resample1(wav1)
|
392 |
+
wav2 = resample2(wav2)
|
393 |
+
|
394 |
+
if use_gpu:
|
395 |
+
wav1 = wav1.cuda(device)
|
396 |
+
wav2 = wav2.cuda(device)
|
397 |
+
with torch.no_grad():
|
398 |
+
emb1 = model(wav1)
|
399 |
+
emb2 = model(wav2)
|
400 |
+
|
401 |
+
sim = F.cosine_similarity(emb1, emb2)[0].item()
|
402 |
+
# print(f"VSim score between two audios: {sim:.4f} (-1.0, 1.0).")
|
403 |
+
sim_list.append(sim)
|
404 |
+
|
405 |
+
return sim_list
|
f5_tts/infer/README.md
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Inference
|
2 |
+
|
3 |
+
The pretrained model checkpoints can be reached at [🤗 Hugging Face](https://huggingface.co/SWivid/F5-TTS) and [🤖 Model Scope](https://www.modelscope.cn/models/SWivid/F5-TTS_Emilia-ZH-EN), or will be automatically downloaded when running inference scripts.
|
4 |
+
|
5 |
+
**More checkpoints with whole community efforts can be found in [SHARED.md](SHARED.md), supporting more languages.**
|
6 |
+
|
7 |
+
Currently support **30s for a single** generation, which is the **total length** including both prompt and output audio. However, you can provide `infer_cli` and `infer_gradio` with longer text, will automatically do chunk generation. Long reference audio will be **clip short to ~15s**.
|
8 |
+
|
9 |
+
To avoid possible inference failures, make sure you have seen through the following instructions.
|
10 |
+
|
11 |
+
- Use reference audio <15s and leave some silence (e.g. 1s) at the end. Otherwise there is a risk of truncating in the middle of word, leading to suboptimal generation.
|
12 |
+
- Uppercased letters will be uttered letter by letter, so use lowercased letters for normal words.
|
13 |
+
- Add some spaces (blank: " ") or punctuations (e.g. "," ".") to explicitly introduce some pauses.
|
14 |
+
- Preprocess numbers to Chinese letters if you want to have them read in Chinese, otherwise in English.
|
15 |
+
- If the generation output is blank (pure silence), check for ffmpeg installation (various tutorials online, blogs, videos, etc.).
|
16 |
+
- Try turn off use_ema if using an early-stage finetuned checkpoint (which goes just few updates).
|
17 |
+
|
18 |
+
|
19 |
+
## Gradio App
|
20 |
+
|
21 |
+
Currently supported features:
|
22 |
+
|
23 |
+
- Basic TTS with Chunk Inference
|
24 |
+
- Multi-Style / Multi-Speaker Generation
|
25 |
+
- Voice Chat powered by Qwen2.5-3B-Instruct
|
26 |
+
|
27 |
+
The cli command `f5-tts_infer-gradio` equals to `python src/f5_tts/infer/infer_gradio.py`, which launches a Gradio APP (web interface) for inference.
|
28 |
+
|
29 |
+
The script will load model checkpoints from Huggingface. You can also manually download files and update the path to `load_model()` in `infer_gradio.py`. Currently only load TTS models first, will load ASR model to do transcription if `ref_text` not provided, will load LLM model if use Voice Chat.
|
30 |
+
|
31 |
+
Could also be used as a component for larger application.
|
32 |
+
```python
|
33 |
+
import gradio as gr
|
34 |
+
from f5_tts.infer.infer_gradio import app
|
35 |
+
|
36 |
+
with gr.Blocks() as main_app:
|
37 |
+
gr.Markdown("# This is an example of using F5-TTS within a bigger Gradio app")
|
38 |
+
|
39 |
+
# ... other Gradio components
|
40 |
+
|
41 |
+
app.render()
|
42 |
+
|
43 |
+
main_app.launch()
|
44 |
+
```
|
45 |
+
|
46 |
+
|
47 |
+
## CLI Inference
|
48 |
+
|
49 |
+
The cli command `f5-tts_infer-cli` equals to `python src/f5_tts/infer/infer_cli.py`, which is a command line tool for inference.
|
50 |
+
|
51 |
+
The script will load model checkpoints from Huggingface. You can also manually download files and use `--ckpt_file` to specify the model you want to load, or directly update in `infer_cli.py`.
|
52 |
+
|
53 |
+
For change vocab.txt use `--vocab_file` to provide your `vocab.txt` file.
|
54 |
+
|
55 |
+
Basically you can inference with flags:
|
56 |
+
```bash
|
57 |
+
# Leave --ref_text "" will have ASR model transcribe (extra GPU memory usage)
|
58 |
+
f5-tts_infer-cli \
|
59 |
+
--model "F5-TTS" \
|
60 |
+
--ref_audio "ref_audio.wav" \
|
61 |
+
--ref_text "The content, subtitle or transcription of reference audio." \
|
62 |
+
--gen_text "Some text you want TTS model generate for you."
|
63 |
+
|
64 |
+
# Choose Vocoder
|
65 |
+
f5-tts_infer-cli --vocoder_name bigvgan --load_vocoder_from_local --ckpt_file <YOUR_CKPT_PATH, eg:ckpts/F5TTS_Base_bigvgan/model_1250000.pt>
|
66 |
+
f5-tts_infer-cli --vocoder_name vocos --load_vocoder_from_local --ckpt_file <YOUR_CKPT_PATH, eg:ckpts/F5TTS_Base/model_1200000.safetensors>
|
67 |
+
```
|
68 |
+
|
69 |
+
And a `.toml` file would help with more flexible usage.
|
70 |
+
|
71 |
+
```bash
|
72 |
+
f5-tts_infer-cli -c custom.toml
|
73 |
+
```
|
74 |
+
|
75 |
+
For example, you can use `.toml` to pass in variables, refer to `src/f5_tts/infer/examples/basic/basic.toml`:
|
76 |
+
|
77 |
+
```toml
|
78 |
+
# F5-TTS | E2-TTS
|
79 |
+
model = "F5-TTS"
|
80 |
+
ref_audio = "infer/examples/basic/basic_ref_en.wav"
|
81 |
+
# If an empty "", transcribes the reference audio automatically.
|
82 |
+
ref_text = "Some call me nature, others call me mother nature."
|
83 |
+
gen_text = "I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring."
|
84 |
+
# File with text to generate. Ignores the text above.
|
85 |
+
gen_file = ""
|
86 |
+
remove_silence = false
|
87 |
+
output_dir = "tests"
|
88 |
+
```
|
89 |
+
|
90 |
+
You can also leverage `.toml` file to do multi-style generation, refer to `src/f5_tts/infer/examples/multi/story.toml`.
|
91 |
+
|
92 |
+
```toml
|
93 |
+
# F5-TTS | E2-TTS
|
94 |
+
model = "F5-TTS"
|
95 |
+
ref_audio = "infer/examples/multi/main.flac"
|
96 |
+
# If an empty "", transcribes the reference audio automatically.
|
97 |
+
ref_text = ""
|
98 |
+
gen_text = ""
|
99 |
+
# File with text to generate. Ignores the text above.
|
100 |
+
gen_file = "infer/examples/multi/story.txt"
|
101 |
+
remove_silence = true
|
102 |
+
output_dir = "tests"
|
103 |
+
|
104 |
+
[voices.town]
|
105 |
+
ref_audio = "infer/examples/multi/town.flac"
|
106 |
+
ref_text = ""
|
107 |
+
|
108 |
+
[voices.country]
|
109 |
+
ref_audio = "infer/examples/multi/country.flac"
|
110 |
+
ref_text = ""
|
111 |
+
```
|
112 |
+
You should mark the voice with `[main]` `[town]` `[country]` whenever you want to change voice, refer to `src/f5_tts/infer/examples/multi/story.txt`.
|
113 |
+
|
114 |
+
## Speech Editing
|
115 |
+
|
116 |
+
To test speech editing capabilities, use the following command:
|
117 |
+
|
118 |
+
```bash
|
119 |
+
python src/f5_tts/infer/speech_edit.py
|
120 |
+
```
|
121 |
+
|
122 |
+
## Socket Realtime Client
|
123 |
+
|
124 |
+
To communicate with socket server you need to run
|
125 |
+
```bash
|
126 |
+
python src/f5_tts/socket_server.py
|
127 |
+
```
|
128 |
+
|
129 |
+
<details>
|
130 |
+
<summary>Then create client to communicate</summary>
|
131 |
+
|
132 |
+
``` python
|
133 |
+
import socket
|
134 |
+
import numpy as np
|
135 |
+
import asyncio
|
136 |
+
import pyaudio
|
137 |
+
|
138 |
+
async def listen_to_voice(text, server_ip='localhost', server_port=9999):
|
139 |
+
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
140 |
+
client_socket.connect((server_ip, server_port))
|
141 |
+
|
142 |
+
async def play_audio_stream():
|
143 |
+
buffer = b''
|
144 |
+
p = pyaudio.PyAudio()
|
145 |
+
stream = p.open(format=pyaudio.paFloat32,
|
146 |
+
channels=1,
|
147 |
+
rate=24000, # Ensure this matches the server's sampling rate
|
148 |
+
output=True,
|
149 |
+
frames_per_buffer=2048)
|
150 |
+
|
151 |
+
try:
|
152 |
+
while True:
|
153 |
+
chunk = await asyncio.get_event_loop().run_in_executor(None, client_socket.recv, 1024)
|
154 |
+
if not chunk: # End of stream
|
155 |
+
break
|
156 |
+
if b"END_OF_AUDIO" in chunk:
|
157 |
+
buffer += chunk.replace(b"END_OF_AUDIO", b"")
|
158 |
+
if buffer:
|
159 |
+
audio_array = np.frombuffer(buffer, dtype=np.float32).copy() # Make a writable copy
|
160 |
+
stream.write(audio_array.tobytes())
|
161 |
+
break
|
162 |
+
buffer += chunk
|
163 |
+
if len(buffer) >= 4096:
|
164 |
+
audio_array = np.frombuffer(buffer[:4096], dtype=np.float32).copy() # Make a writable copy
|
165 |
+
stream.write(audio_array.tobytes())
|
166 |
+
buffer = buffer[4096:]
|
167 |
+
finally:
|
168 |
+
stream.stop_stream()
|
169 |
+
stream.close()
|
170 |
+
p.terminate()
|
171 |
+
|
172 |
+
try:
|
173 |
+
# Send only the text to the server
|
174 |
+
await asyncio.get_event_loop().run_in_executor(None, client_socket.sendall, text.encode('utf-8'))
|
175 |
+
await play_audio_stream()
|
176 |
+
print("Audio playback finished.")
|
177 |
+
|
178 |
+
except Exception as e:
|
179 |
+
print(f"Error in listen_to_voice: {e}")
|
180 |
+
|
181 |
+
finally:
|
182 |
+
client_socket.close()
|
183 |
+
|
184 |
+
# Example usage: Replace this with your actual server IP and port
|
185 |
+
async def main():
|
186 |
+
await listen_to_voice("my name is jenny..", server_ip='localhost', server_port=9998)
|
187 |
+
|
188 |
+
# Run the main async function
|
189 |
+
asyncio.run(main())
|
190 |
+
```
|
191 |
+
|
192 |
+
</details>
|
193 |
+
|
f5_tts/infer/SHARED.md
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- omit in toc -->
|
2 |
+
# Shared Model Cards
|
3 |
+
|
4 |
+
<!-- omit in toc -->
|
5 |
+
### **Prerequisites of using**
|
6 |
+
- This document is serving as a quick lookup table for the community training/finetuning result, with various language support.
|
7 |
+
- The models in this repository are open source and are based on voluntary contributions from contributors.
|
8 |
+
- The use of models must be conditioned on respect for the respective creators. The convenience brought comes from their efforts.
|
9 |
+
|
10 |
+
<!-- omit in toc -->
|
11 |
+
### **Welcome to share here**
|
12 |
+
- Have a pretrained/finetuned result: model checkpoint (pruned best to facilitate inference, i.e. leave only `ema_model_state_dict`) and corresponding vocab file (for tokenization).
|
13 |
+
- Host a public [huggingface model repository](https://huggingface.co/new) and upload the model related files.
|
14 |
+
- Make a pull request adding a model card to the current page, i.e. `src\f5_tts\infer\SHARED.md`.
|
15 |
+
|
16 |
+
<!-- omit in toc -->
|
17 |
+
### Supported Languages
|
18 |
+
- [Multilingual](#multilingual)
|
19 |
+
- [F5-TTS Base @ pretrain @ zh \& en](#f5-tts-base--pretrain--zh--en)
|
20 |
+
- [English](#english)
|
21 |
+
- [Finnish](#finnish)
|
22 |
+
- [Finnish Common\_Voice Vox\_Populi @ finetune @ fi](#finnish-common_voice-vox_populi--finetune--fi)
|
23 |
+
- [French](#french)
|
24 |
+
- [French LibriVox @ finetune @ fr](#french-librivox--finetune--fr)
|
25 |
+
- [Japanese](#japanese)
|
26 |
+
- [F5-TTS Japanese @ pretrain/finetune @ ja](#f5-tts-japanese--pretrainfinetune--ja)
|
27 |
+
- [Mandarin](#mandarin)
|
28 |
+
- [Spanish](#spanish)
|
29 |
+
- [F5-TTS Spanish @ pretrain/finetune @ es](#f5-tts-spanish--pretrainfinetune--es)
|
30 |
+
|
31 |
+
|
32 |
+
## Multilingual
|
33 |
+
|
34 |
+
#### F5-TTS Base @ pretrain @ zh & en
|
35 |
+
|Model|🤗Hugging Face|Data (Hours)|Model License|
|
36 |
+
|:---:|:------------:|:-----------:|:-------------:|
|
37 |
+
|F5-TTS Base|[ckpt & vocab](https://huggingface.co/SWivid/F5-TTS/tree/main/F5TTS_Base)|[Emilia 95K zh&en](https://huggingface.co/datasets/amphion/Emilia-Dataset/tree/fc71e07)|cc-by-nc-4.0|
|
38 |
+
|
39 |
+
```bash
|
40 |
+
MODEL_CKPT: hf://SWivid/F5-TTS/F5TTS_Base/model_1200000.safetensors
|
41 |
+
VOCAB_FILE: hf://SWivid/F5-TTS/F5TTS_Base/vocab.txt
|
42 |
+
```
|
43 |
+
|
44 |
+
*Other infos, e.g. Author info, Github repo, Link to some sampled results, Usage instruction, Tutorial (Blog, Video, etc.) ...*
|
45 |
+
|
46 |
+
|
47 |
+
## English
|
48 |
+
|
49 |
+
|
50 |
+
## Finnish
|
51 |
+
|
52 |
+
#### Finnish Common_Voice Vox_Populi @ finetune @ fi
|
53 |
+
|Model|🤗Hugging Face|Data|Model License|
|
54 |
+
|:---:|:------------:|:-----------:|:-------------:|
|
55 |
+
|F5-TTS Finnish|[ckpt & vocab](https://huggingface.co/AsmoKoskinen/F5-TTS_Finnish_Model)|[Common Voice](https://huggingface.co/datasets/mozilla-foundation/common_voice_17_0), [Vox Populi](https://huggingface.co/datasets/facebook/voxpopuli)|cc-by-nc-4.0|
|
56 |
+
|
57 |
+
```bash
|
58 |
+
MODEL_CKPT: hf://AsmoKoskinen/F5-TTS_Finish_Model/model_common_voice_fi_vox_populi_fi_20241206.safetensors
|
59 |
+
VOCAB_FILE: hf://AsmoKoskinen/F5-TTS_Finish_Model/vocab.txt
|
60 |
+
```
|
61 |
+
|
62 |
+
|
63 |
+
## French
|
64 |
+
|
65 |
+
#### French LibriVox @ finetune @ fr
|
66 |
+
|Model|🤗Hugging Face|Data (Hours)|Model License|
|
67 |
+
|:---:|:------------:|:-----------:|:-------------:|
|
68 |
+
|F5-TTS French|[ckpt & vocab](https://huggingface.co/RASPIAUDIO/F5-French-MixedSpeakers-reduced)|[LibriVox](https://librivox.org/)|cc-by-nc-4.0|
|
69 |
+
|
70 |
+
```bash
|
71 |
+
MODEL_CKPT: hf://RASPIAUDIO/F5-French-MixedSpeakers-reduced/model_last_reduced.pt
|
72 |
+
VOCAB_FILE: hf://RASPIAUDIO/F5-French-MixedSpeakers-reduced/vocab.txt
|
73 |
+
```
|
74 |
+
|
75 |
+
- [Online Inference with Hugging Face Space](https://huggingface.co/spaces/RASPIAUDIO/f5-tts_french).
|
76 |
+
- [Tutorial video to train a new language model](https://www.youtube.com/watch?v=UO4usaOojys).
|
77 |
+
- [Discussion about this training can be found here](https://github.com/SWivid/F5-TTS/issues/434).
|
78 |
+
|
79 |
+
|
80 |
+
## Japanese
|
81 |
+
|
82 |
+
#### F5-TTS Japanese @ pretrain/finetune @ ja
|
83 |
+
|Model|🤗Hugging Face|Data (Hours)|Model License|
|
84 |
+
|:---:|:------------:|:-----------:|:-------------:|
|
85 |
+
|F5-TTS Japanese|[ckpt & vocab](https://huggingface.co/Jmica/F5TTS/tree/main/JA_8500000)|[Emilia 1.7k JA](https://huggingface.co/datasets/amphion/Emilia-Dataset/tree/fc71e07) & [Galgame Dataset 5.4k](https://huggingface.co/datasets/OOPPEENN/Galgame_Dataset)|cc-by-nc-4.0|
|
86 |
+
|
87 |
+
```bash
|
88 |
+
MODEL_CKPT: hf://Jmica/F5TTS/JA_8500000/model_8499660.pt
|
89 |
+
VOCAB_FILE: hf://Jmica/F5TTS/JA_8500000/vocab_updated.txt
|
90 |
+
```
|
91 |
+
|
92 |
+
|
93 |
+
## Mandarin
|
94 |
+
|
95 |
+
|
96 |
+
## Spanish
|
97 |
+
|
98 |
+
#### F5-TTS Spanish @ pretrain/finetune @ es
|
99 |
+
|Model|🤗Hugging Face|Data (Hours)|Model License|
|
100 |
+
|:---:|:------------:|:-----------:|:-------------:|
|
101 |
+
|F5-TTS Spanish|[ckpt & vocab](https://huggingface.co/jpgallegoar/F5-Spanish)|[Voxpopuli](https://huggingface.co/datasets/facebook/voxpopuli) & Crowdsourced & TEDx, 218 hours|cc0-1.0|
|
102 |
+
|
103 |
+
- @jpgallegoar [GitHub repo](https://github.com/jpgallegoar/Spanish-F5), Jupyter Notebook and Gradio usage for Spanish model.
|
f5_tts/infer/__pycache__/utils_infer.cpython-310.pyc
ADDED
Binary file (11 kB). View file
|
|
f5_tts/infer/__pycache__/utils_infer.cpython-312.pyc
ADDED
Binary file (19.2 kB). View file
|
|
f5_tts/infer/examples/basic/basic.toml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# F5-TTS | E2-TTS
|
2 |
+
model = "F5-TTS"
|
3 |
+
ref_audio = "infer/examples/basic/basic_ref_en.wav"
|
4 |
+
# If an empty "", transcribes the reference audio automatically.
|
5 |
+
ref_text = "Some call me nature, others call me mother nature."
|
6 |
+
gen_text = "I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring."
|
7 |
+
# File with text to generate. Ignores the text above.
|
8 |
+
gen_file = ""
|
9 |
+
remove_silence = false
|
10 |
+
output_dir = "tests"
|
11 |
+
output_file = "infer_cli_out.wav"
|
f5_tts/infer/examples/basic/basic_ref_en.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b0e22048e72414fcc1e6b6342e47a774d748a195ed34e4a5b3fcf416707f2b71
|
3 |
+
size 256018
|
f5_tts/infer/examples/basic/basic_ref_zh.wav
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:96724a113240d1f82c6ded1334122f0176b96c9226ccd3c919e625bcfd2a3ede
|
3 |
+
size 324558
|
f5_tts/infer/examples/multi/country.flac
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bb15708b4b3875e37beec46591a5d89e1a9a63fdad3b8fe4a5c8738f4f554400
|
3 |
+
size 180321
|
f5_tts/infer/examples/multi/main.flac
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4abb1107771ce7e14926fde879b959dde6db6e572476b98684f04e45e978ab19
|
3 |
+
size 279219
|
f5_tts/infer/examples/multi/story.toml
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# F5-TTS | E2-TTS
|
2 |
+
model = "F5-TTS"
|
3 |
+
ref_audio = "infer/examples/multi/main.flac"
|
4 |
+
# If an empty "", transcribes the reference audio automatically.
|
5 |
+
ref_text = ""
|
6 |
+
gen_text = ""
|
7 |
+
# File with text to generate. Ignores the text above.
|
8 |
+
gen_file = "infer/examples/multi/story.txt"
|
9 |
+
remove_silence = true
|
10 |
+
output_dir = "tests"
|
11 |
+
|
12 |
+
[voices.town]
|
13 |
+
ref_audio = "infer/examples/multi/town.flac"
|
14 |
+
ref_text = ""
|
15 |
+
|
16 |
+
[voices.country]
|
17 |
+
ref_audio = "infer/examples/multi/country.flac"
|
18 |
+
ref_text = ""
|
19 |
+
|
f5_tts/infer/examples/multi/story.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
A Town Mouse and a Country Mouse were acquaintances, and the Country Mouse one day invited his friend to come and see him at his home in the fields. The Town Mouse came, and they sat down to a dinner of barleycorns and roots, the latter of which had a distinctly earthy flavour. The fare was not much to the taste of the guest, and presently he broke out with [town] “My poor dear friend, you live here no better than the ants. Now, you should just see how I fare! My larder is a regular horn of plenty. You must come and stay with me, and I promise you you shall live on the fat of the land.” [main] So when he returned to town he took the Country Mouse with him, and showed him into a larder containing flour and oatmeal and figs and honey and dates. The Country Mouse had never seen anything like it, and sat down to enjoy the luxuries his friend provided: but before they had well begun, the door of the larder opened and someone came in. The two Mice scampered off and hid themselves in a narrow and exceedingly uncomfortable hole. Presently, when all was quiet, they ventured out again; but someone else came in, and off they scuttled again. This was too much for the visitor. [country] “Goodbye,” [main] said he, [country] “I’m off. You live in the lap of luxury, I can see, but you are surrounded by dangers; whereas at home I can enjoy my simple dinner of roots and corn in peace.”
|
f5_tts/infer/examples/multi/town.flac
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |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|
+
ban2
|
91 |
+
ban3
|
92 |
+
ban4
|
93 |
+
bang1
|
94 |
+
bang2
|
95 |
+
bang3
|
96 |
+
bang4
|
97 |
+
bao1
|
98 |
+
bao2
|
99 |
+
bao3
|
100 |
+
bao4
|
101 |
+
bei
|
102 |
+
bei1
|
103 |
+
bei2
|
104 |
+
bei3
|
105 |
+
bei4
|
106 |
+
ben1
|
107 |
+
ben2
|
108 |
+
ben3
|
109 |
+
ben4
|
110 |
+
beng
|
111 |
+
beng1
|
112 |
+
beng2
|
113 |
+
beng3
|
114 |
+
beng4
|
115 |
+
bi1
|
116 |
+
bi2
|
117 |
+
bi3
|
118 |
+
bi4
|
119 |
+
bian1
|
120 |
+
bian2
|
121 |
+
bian3
|
122 |
+
bian4
|
123 |
+
biao1
|
124 |
+
biao2
|
125 |
+
biao3
|
126 |
+
bie1
|
127 |
+
bie2
|
128 |
+
bie3
|
129 |
+
bie4
|
130 |
+
bin1
|
131 |
+
bin4
|
132 |
+
bing1
|
133 |
+
bing2
|
134 |
+
bing3
|
135 |
+
bing4
|
136 |
+
bo
|
137 |
+
bo1
|
138 |
+
bo2
|
139 |
+
bo3
|
140 |
+
bo4
|
141 |
+
bu2
|
142 |
+
bu3
|
143 |
+
bu4
|
144 |
+
c
|
145 |
+
ca1
|
146 |
+
cai1
|
147 |
+
cai2
|
148 |
+
cai3
|
149 |
+
cai4
|
150 |
+
can1
|
151 |
+
can2
|
152 |
+
can3
|
153 |
+
can4
|
154 |
+
cang1
|
155 |
+
cang2
|
156 |
+
cao1
|
157 |
+
cao2
|
158 |
+
cao3
|
159 |
+
ce4
|
160 |
+
cen1
|
161 |
+
cen2
|
162 |
+
ceng1
|
163 |
+
ceng2
|
164 |
+
ceng4
|
165 |
+
cha1
|
166 |
+
cha2
|
167 |
+
cha3
|
168 |
+
cha4
|
169 |
+
chai1
|
170 |
+
chai2
|
171 |
+
chan1
|
172 |
+
chan2
|
173 |
+
chan3
|
174 |
+
chan4
|
175 |
+
chang1
|
176 |
+
chang2
|
177 |
+
chang3
|
178 |
+
chang4
|
179 |
+
chao1
|
180 |
+
chao2
|
181 |
+
chao3
|
182 |
+
che1
|
183 |
+
che2
|
184 |
+
che3
|
185 |
+
che4
|
186 |
+
chen1
|
187 |
+
chen2
|
188 |
+
chen3
|
189 |
+
chen4
|
190 |
+
cheng1
|
191 |
+
cheng2
|
192 |
+
cheng3
|
193 |
+
cheng4
|
194 |
+
chi1
|
195 |
+
chi2
|
196 |
+
chi3
|
197 |
+
chi4
|
198 |
+
chong1
|
199 |
+
chong2
|
200 |
+
chong3
|
201 |
+
chong4
|
202 |
+
chou1
|
203 |
+
chou2
|
204 |
+
chou3
|
205 |
+
chou4
|
206 |
+
chu1
|
207 |
+
chu2
|
208 |
+
chu3
|
209 |
+
chu4
|
210 |
+
chua1
|
211 |
+
chuai1
|
212 |
+
chuai2
|
213 |
+
chuai3
|
214 |
+
chuai4
|
215 |
+
chuan1
|
216 |
+
chuan2
|
217 |
+
chuan3
|
218 |
+
chuan4
|
219 |
+
chuang1
|
220 |
+
chuang2
|
221 |
+
chuang3
|
222 |
+
chuang4
|
223 |
+
chui1
|
224 |
+
chui2
|
225 |
+
chun1
|
226 |
+
chun2
|
227 |
+
chun3
|
228 |
+
chuo1
|
229 |
+
chuo4
|
230 |
+
ci1
|
231 |
+
ci2
|
232 |
+
ci3
|
233 |
+
ci4
|
234 |
+
cong1
|
235 |
+
cong2
|
236 |
+
cou4
|
237 |
+
cu1
|
238 |
+
cu4
|
239 |
+
cuan1
|
240 |
+
cuan2
|
241 |
+
cuan4
|
242 |
+
cui1
|
243 |
+
cui3
|
244 |
+
cui4
|
245 |
+
cun1
|
246 |
+
cun2
|
247 |
+
cun4
|
248 |
+
cuo1
|
249 |
+
cuo2
|
250 |
+
cuo4
|
251 |
+
d
|
252 |
+
da
|
253 |
+
da1
|
254 |
+
da2
|
255 |
+
da3
|
256 |
+
da4
|
257 |
+
dai1
|
258 |
+
dai2
|
259 |
+
dai3
|
260 |
+
dai4
|
261 |
+
dan1
|
262 |
+
dan2
|
263 |
+
dan3
|
264 |
+
dan4
|
265 |
+
dang1
|
266 |
+
dang2
|
267 |
+
dang3
|
268 |
+
dang4
|
269 |
+
dao1
|
270 |
+
dao2
|
271 |
+
dao3
|
272 |
+
dao4
|
273 |
+
de
|
274 |
+
de1
|
275 |
+
de2
|
276 |
+
dei3
|
277 |
+
den4
|
278 |
+
deng1
|
279 |
+
deng2
|
280 |
+
deng3
|
281 |
+
deng4
|
282 |
+
di1
|
283 |
+
di2
|
284 |
+
di3
|
285 |
+
di4
|
286 |
+
dia3
|
287 |
+
dian1
|
288 |
+
dian2
|
289 |
+
dian3
|
290 |
+
dian4
|
291 |
+
diao1
|
292 |
+
diao3
|
293 |
+
diao4
|
294 |
+
die1
|
295 |
+
die2
|
296 |
+
die4
|
297 |
+
ding1
|
298 |
+
ding2
|
299 |
+
ding3
|
300 |
+
ding4
|
301 |
+
diu1
|
302 |
+
dong1
|
303 |
+
dong3
|
304 |
+
dong4
|
305 |
+
dou1
|
306 |
+
dou2
|
307 |
+
dou3
|
308 |
+
dou4
|
309 |
+
du1
|
310 |
+
du2
|
311 |
+
du3
|
312 |
+
du4
|
313 |
+
duan1
|
314 |
+
duan2
|
315 |
+
duan3
|
316 |
+
duan4
|
317 |
+
dui1
|
318 |
+
dui4
|
319 |
+
dun1
|
320 |
+
dun3
|
321 |
+
dun4
|
322 |
+
duo1
|
323 |
+
duo2
|
324 |
+
duo3
|
325 |
+
duo4
|
326 |
+
e
|
327 |
+
e1
|
328 |
+
e2
|
329 |
+
e3
|
330 |
+
e4
|
331 |
+
ei2
|
332 |
+
en1
|
333 |
+
en4
|
334 |
+
er
|
335 |
+
er2
|
336 |
+
er3
|
337 |
+
er4
|
338 |
+
f
|
339 |
+
fa1
|
340 |
+
fa2
|
341 |
+
fa3
|
342 |
+
fa4
|
343 |
+
fan1
|
344 |
+
fan2
|
345 |
+
fan3
|
346 |
+
fan4
|
347 |
+
fang1
|
348 |
+
fang2
|
349 |
+
fang3
|
350 |
+
fang4
|
351 |
+
fei1
|
352 |
+
fei2
|
353 |
+
fei3
|
354 |
+
fei4
|
355 |
+
fen1
|
356 |
+
fen2
|
357 |
+
fen3
|
358 |
+
fen4
|
359 |
+
feng1
|
360 |
+
feng2
|
361 |
+
feng3
|
362 |
+
feng4
|
363 |
+
fo2
|
364 |
+
fou2
|
365 |
+
fou3
|
366 |
+
fu1
|
367 |
+
fu2
|
368 |
+
fu3
|
369 |
+
fu4
|
370 |
+
g
|
371 |
+
ga1
|
372 |
+
ga2
|
373 |
+
ga3
|
374 |
+
ga4
|
375 |
+
gai1
|
376 |
+
gai2
|
377 |
+
gai3
|
378 |
+
gai4
|
379 |
+
gan1
|
380 |
+
gan2
|
381 |
+
gan3
|
382 |
+
gan4
|
383 |
+
gang1
|
384 |
+
gang2
|
385 |
+
gang3
|
386 |
+
gang4
|
387 |
+
gao1
|
388 |
+
gao2
|
389 |
+
gao3
|
390 |
+
gao4
|
391 |
+
ge1
|
392 |
+
ge2
|
393 |
+
ge3
|
394 |
+
ge4
|
395 |
+
gei2
|
396 |
+
gei3
|
397 |
+
gen1
|
398 |
+
gen2
|
399 |
+
gen3
|
400 |
+
gen4
|
401 |
+
geng1
|
402 |
+
geng3
|
403 |
+
geng4
|
404 |
+
gong1
|
405 |
+
gong3
|
406 |
+
gong4
|
407 |
+
gou1
|
408 |
+
gou2
|
409 |
+
gou3
|
410 |
+
gou4
|
411 |
+
gu
|
412 |
+
gu1
|
413 |
+
gu2
|
414 |
+
gu3
|
415 |
+
gu4
|
416 |
+
gua1
|
417 |
+
gua2
|
418 |
+
gua3
|
419 |
+
gua4
|
420 |
+
guai1
|
421 |
+
guai2
|
422 |
+
guai3
|
423 |
+
guai4
|
424 |
+
guan1
|
425 |
+
guan2
|
426 |
+
guan3
|
427 |
+
guan4
|
428 |
+
guang1
|
429 |
+
guang2
|
430 |
+
guang3
|
431 |
+
guang4
|
432 |
+
gui1
|
433 |
+
gui2
|
434 |
+
gui3
|
435 |
+
gui4
|
436 |
+
gun3
|
437 |
+
gun4
|
438 |
+
guo1
|
439 |
+
guo2
|
440 |
+
guo3
|
441 |
+
guo4
|
442 |
+
h
|
443 |
+
ha1
|
444 |
+
ha2
|
445 |
+
ha3
|
446 |
+
hai1
|
447 |
+
hai2
|
448 |
+
hai3
|
449 |
+
hai4
|
450 |
+
han1
|
451 |
+
han2
|
452 |
+
han3
|
453 |
+
han4
|
454 |
+
hang1
|
455 |
+
hang2
|
456 |
+
hang4
|
457 |
+
hao1
|
458 |
+
hao2
|
459 |
+
hao3
|
460 |
+
hao4
|
461 |
+
he1
|
462 |
+
he2
|
463 |
+
he4
|
464 |
+
hei1
|
465 |
+
hen2
|
466 |
+
hen3
|
467 |
+
hen4
|
468 |
+
heng1
|
469 |
+
heng2
|
470 |
+
heng4
|
471 |
+
hong1
|
472 |
+
hong2
|
473 |
+
hong3
|
474 |
+
hong4
|
475 |
+
hou1
|
476 |
+
hou2
|
477 |
+
hou3
|
478 |
+
hou4
|
479 |
+
hu1
|
480 |
+
hu2
|
481 |
+
hu3
|
482 |
+
hu4
|
483 |
+
hua1
|
484 |
+
hua2
|
485 |
+
hua4
|
486 |
+
huai2
|
487 |
+
huai4
|
488 |
+
huan1
|
489 |
+
huan2
|
490 |
+
huan3
|
491 |
+
huan4
|
492 |
+
huang1
|
493 |
+
huang2
|
494 |
+
huang3
|
495 |
+
huang4
|
496 |
+
hui1
|
497 |
+
hui2
|
498 |
+
hui3
|
499 |
+
hui4
|
500 |
+
hun1
|
501 |
+
hun2
|
502 |
+
hun4
|
503 |
+
huo
|
504 |
+
huo1
|
505 |
+
huo2
|
506 |
+
huo3
|
507 |
+
huo4
|
508 |
+
i
|
509 |
+
j
|
510 |
+
ji1
|
511 |
+
ji2
|
512 |
+
ji3
|
513 |
+
ji4
|
514 |
+
jia
|
515 |
+
jia1
|
516 |
+
jia2
|
517 |
+
jia3
|
518 |
+
jia4
|
519 |
+
jian1
|
520 |
+
jian2
|
521 |
+
jian3
|
522 |
+
jian4
|
523 |
+
jiang1
|
524 |
+
jiang2
|
525 |
+
jiang3
|
526 |
+
jiang4
|
527 |
+
jiao1
|
528 |
+
jiao2
|
529 |
+
jiao3
|
530 |
+
jiao4
|
531 |
+
jie1
|
532 |
+
jie2
|
533 |
+
jie3
|
534 |
+
jie4
|
535 |
+
jin1
|
536 |
+
jin2
|
537 |
+
jin3
|
538 |
+
jin4
|
539 |
+
jing1
|
540 |
+
jing2
|
541 |
+
jing3
|
542 |
+
jing4
|
543 |
+
jiong3
|
544 |
+
jiu1
|
545 |
+
jiu2
|
546 |
+
jiu3
|
547 |
+
jiu4
|
548 |
+
ju1
|
549 |
+
ju2
|
550 |
+
ju3
|
551 |
+
ju4
|
552 |
+
juan1
|
553 |
+
juan2
|
554 |
+
juan3
|
555 |
+
juan4
|
556 |
+
jue1
|
557 |
+
jue2
|
558 |
+
jue4
|
559 |
+
jun1
|
560 |
+
jun4
|
561 |
+
k
|
562 |
+
ka1
|
563 |
+
ka2
|
564 |
+
ka3
|
565 |
+
kai1
|
566 |
+
kai2
|
567 |
+
kai3
|
568 |
+
kai4
|
569 |
+
kan1
|
570 |
+
kan2
|
571 |
+
kan3
|
572 |
+
kan4
|
573 |
+
kang1
|
574 |
+
kang2
|
575 |
+
kang4
|
576 |
+
kao1
|
577 |
+
kao2
|
578 |
+
kao3
|
579 |
+
kao4
|
580 |
+
ke1
|
581 |
+
ke2
|
582 |
+
ke3
|
583 |
+
ke4
|
584 |
+
ken3
|
585 |
+
keng1
|
586 |
+
kong1
|
587 |
+
kong3
|
588 |
+
kong4
|
589 |
+
kou1
|
590 |
+
kou2
|
591 |
+
kou3
|
592 |
+
kou4
|
593 |
+
ku1
|
594 |
+
ku2
|
595 |
+
ku3
|
596 |
+
ku4
|
597 |
+
kua1
|
598 |
+
kua3
|
599 |
+
kua4
|
600 |
+
kuai3
|
601 |
+
kuai4
|
602 |
+
kuan1
|
603 |
+
kuan2
|
604 |
+
kuan3
|
605 |
+
kuang1
|
606 |
+
kuang2
|
607 |
+
kuang4
|
608 |
+
kui1
|
609 |
+
kui2
|
610 |
+
kui3
|
611 |
+
kui4
|
612 |
+
kun1
|
613 |
+
kun3
|
614 |
+
kun4
|
615 |
+
kuo4
|
616 |
+
l
|
617 |
+
la
|
618 |
+
la1
|
619 |
+
la2
|
620 |
+
la3
|
621 |
+
la4
|
622 |
+
lai2
|
623 |
+
lai4
|
624 |
+
lan2
|
625 |
+
lan3
|
626 |
+
lan4
|
627 |
+
lang1
|
628 |
+
lang2
|
629 |
+
lang3
|
630 |
+
lang4
|
631 |
+
lao1
|
632 |
+
lao2
|
633 |
+
lao3
|
634 |
+
lao4
|
635 |
+
le
|
636 |
+
le1
|
637 |
+
le4
|
638 |
+
lei
|
639 |
+
lei1
|
640 |
+
lei2
|
641 |
+
lei3
|
642 |
+
lei4
|
643 |
+
leng1
|
644 |
+
leng2
|
645 |
+
leng3
|
646 |
+
leng4
|
647 |
+
li
|
648 |
+
li1
|
649 |
+
li2
|
650 |
+
li3
|
651 |
+
li4
|
652 |
+
lia3
|
653 |
+
lian2
|
654 |
+
lian3
|
655 |
+
lian4
|
656 |
+
liang2
|
657 |
+
liang3
|
658 |
+
liang4
|
659 |
+
liao1
|
660 |
+
liao2
|
661 |
+
liao3
|
662 |
+
liao4
|
663 |
+
lie1
|
664 |
+
lie2
|
665 |
+
lie3
|
666 |
+
lie4
|
667 |
+
lin1
|
668 |
+
lin2
|
669 |
+
lin3
|
670 |
+
lin4
|
671 |
+
ling2
|
672 |
+
ling3
|
673 |
+
ling4
|
674 |
+
liu1
|
675 |
+
liu2
|
676 |
+
liu3
|
677 |
+
liu4
|
678 |
+
long1
|
679 |
+
long2
|
680 |
+
long3
|
681 |
+
long4
|
682 |
+
lou1
|
683 |
+
lou2
|
684 |
+
lou3
|
685 |
+
lou4
|
686 |
+
lu1
|
687 |
+
lu2
|
688 |
+
lu3
|
689 |
+
lu4
|
690 |
+
luan2
|
691 |
+
luan3
|
692 |
+
luan4
|
693 |
+
lun1
|
694 |
+
lun2
|
695 |
+
lun4
|
696 |
+
luo1
|
697 |
+
luo2
|
698 |
+
luo3
|
699 |
+
luo4
|
700 |
+
lv2
|
701 |
+
lv3
|
702 |
+
lv4
|
703 |
+
lve3
|
704 |
+
lve4
|
705 |
+
m
|
706 |
+
ma
|
707 |
+
ma1
|
708 |
+
ma2
|
709 |
+
ma3
|
710 |
+
ma4
|
711 |
+
mai2
|
712 |
+
mai3
|
713 |
+
mai4
|
714 |
+
man1
|
715 |
+
man2
|
716 |
+
man3
|
717 |
+
man4
|
718 |
+
mang2
|
719 |
+
mang3
|
720 |
+
mao1
|
721 |
+
mao2
|
722 |
+
mao3
|
723 |
+
mao4
|
724 |
+
me
|
725 |
+
mei2
|
726 |
+
mei3
|
727 |
+
mei4
|
728 |
+
men
|
729 |
+
men1
|
730 |
+
men2
|
731 |
+
men4
|
732 |
+
meng
|
733 |
+
meng1
|
734 |
+
meng2
|
735 |
+
meng3
|
736 |
+
meng4
|
737 |
+
mi1
|
738 |
+
mi2
|
739 |
+
mi3
|
740 |
+
mi4
|
741 |
+
mian2
|
742 |
+
mian3
|
743 |
+
mian4
|
744 |
+
miao1
|
745 |
+
miao2
|
746 |
+
miao3
|
747 |
+
miao4
|
748 |
+
mie1
|
749 |
+
mie4
|
750 |
+
min2
|
751 |
+
min3
|
752 |
+
ming2
|
753 |
+
ming3
|
754 |
+
ming4
|
755 |
+
miu4
|
756 |
+
mo1
|
757 |
+
mo2
|
758 |
+
mo3
|
759 |
+
mo4
|
760 |
+
mou1
|
761 |
+
mou2
|
762 |
+
mou3
|
763 |
+
mu2
|
764 |
+
mu3
|
765 |
+
mu4
|
766 |
+
n
|
767 |
+
n2
|
768 |
+
na1
|
769 |
+
na2
|
770 |
+
na3
|
771 |
+
na4
|
772 |
+
nai2
|
773 |
+
nai3
|
774 |
+
nai4
|
775 |
+
nan1
|
776 |
+
nan2
|
777 |
+
nan3
|
778 |
+
nan4
|
779 |
+
nang1
|
780 |
+
nang2
|
781 |
+
nang3
|
782 |
+
nao1
|
783 |
+
nao2
|
784 |
+
nao3
|
785 |
+
nao4
|
786 |
+
ne
|
787 |
+
ne2
|
788 |
+
ne4
|
789 |
+
nei3
|
790 |
+
nei4
|
791 |
+
nen4
|
792 |
+
neng2
|
793 |
+
ni1
|
794 |
+
ni2
|
795 |
+
ni3
|
796 |
+
ni4
|
797 |
+
nian1
|
798 |
+
nian2
|
799 |
+
nian3
|
800 |
+
nian4
|
801 |
+
niang2
|
802 |
+
niang4
|
803 |
+
niao2
|
804 |
+
niao3
|
805 |
+
niao4
|
806 |
+
nie1
|
807 |
+
nie4
|
808 |
+
nin2
|
809 |
+
ning2
|
810 |
+
ning3
|
811 |
+
ning4
|
812 |
+
niu1
|
813 |
+
niu2
|
814 |
+
niu3
|
815 |
+
niu4
|
816 |
+
nong2
|
817 |
+
nong4
|
818 |
+
nou4
|
819 |
+
nu2
|
820 |
+
nu3
|
821 |
+
nu4
|
822 |
+
nuan3
|
823 |
+
nuo2
|
824 |
+
nuo4
|
825 |
+
nv2
|
826 |
+
nv3
|
827 |
+
nve4
|
828 |
+
o
|
829 |
+
o1
|
830 |
+
o2
|
831 |
+
ou1
|
832 |
+
ou2
|
833 |
+
ou3
|
834 |
+
ou4
|
835 |
+
p
|
836 |
+
pa1
|
837 |
+
pa2
|
838 |
+
pa4
|
839 |
+
pai1
|
840 |
+
pai2
|
841 |
+
pai3
|
842 |
+
pai4
|
843 |
+
pan1
|
844 |
+
pan2
|
845 |
+
pan4
|
846 |
+
pang1
|
847 |
+
pang2
|
848 |
+
pang4
|
849 |
+
pao1
|
850 |
+
pao2
|
851 |
+
pao3
|
852 |
+
pao4
|
853 |
+
pei1
|
854 |
+
pei2
|
855 |
+
pei4
|
856 |
+
pen1
|
857 |
+
pen2
|
858 |
+
pen4
|
859 |
+
peng1
|
860 |
+
peng2
|
861 |
+
peng3
|
862 |
+
peng4
|
863 |
+
pi1
|
864 |
+
pi2
|
865 |
+
pi3
|
866 |
+
pi4
|
867 |
+
pian1
|
868 |
+
pian2
|
869 |
+
pian4
|
870 |
+
piao1
|
871 |
+
piao2
|
872 |
+
piao3
|
873 |
+
piao4
|
874 |
+
pie1
|
875 |
+
pie2
|
876 |
+
pie3
|
877 |
+
pin1
|
878 |
+
pin2
|
879 |
+
pin3
|
880 |
+
pin4
|
881 |
+
ping1
|
882 |
+
ping2
|
883 |
+
po1
|
884 |
+
po2
|
885 |
+
po3
|
886 |
+
po4
|
887 |
+
pou1
|
888 |
+
pu1
|
889 |
+
pu2
|
890 |
+
pu3
|
891 |
+
pu4
|
892 |
+
q
|
893 |
+
qi1
|
894 |
+
qi2
|
895 |
+
qi3
|
896 |
+
qi4
|
897 |
+
qia1
|
898 |
+
qia3
|
899 |
+
qia4
|
900 |
+
qian1
|
901 |
+
qian2
|
902 |
+
qian3
|
903 |
+
qian4
|
904 |
+
qiang1
|
905 |
+
qiang2
|
906 |
+
qiang3
|
907 |
+
qiang4
|
908 |
+
qiao1
|
909 |
+
qiao2
|
910 |
+
qiao3
|
911 |
+
qiao4
|
912 |
+
qie1
|
913 |
+
qie2
|
914 |
+
qie3
|
915 |
+
qie4
|
916 |
+
qin1
|
917 |
+
qin2
|
918 |
+
qin3
|
919 |
+
qin4
|
920 |
+
qing1
|
921 |
+
qing2
|
922 |
+
qing3
|
923 |
+
qing4
|
924 |
+
qiong1
|
925 |
+
qiong2
|
926 |
+
qiu1
|
927 |
+
qiu2
|
928 |
+
qiu3
|
929 |
+
qu1
|
930 |
+
qu2
|
931 |
+
qu3
|
932 |
+
qu4
|
933 |
+
quan1
|
934 |
+
quan2
|
935 |
+
quan3
|
936 |
+
quan4
|
937 |
+
que1
|
938 |
+
que2
|
939 |
+
que4
|
940 |
+
qun2
|
941 |
+
r
|
942 |
+
ran2
|
943 |
+
ran3
|
944 |
+
rang1
|
945 |
+
rang2
|
946 |
+
rang3
|
947 |
+
rang4
|
948 |
+
rao2
|
949 |
+
rao3
|
950 |
+
rao4
|
951 |
+
re2
|
952 |
+
re3
|
953 |
+
re4
|
954 |
+
ren2
|
955 |
+
ren3
|
956 |
+
ren4
|
957 |
+
reng1
|
958 |
+
reng2
|
959 |
+
ri4
|
960 |
+
rong1
|
961 |
+
rong2
|
962 |
+
rong3
|
963 |
+
rou2
|
964 |
+
rou4
|
965 |
+
ru2
|
966 |
+
ru3
|
967 |
+
ru4
|
968 |
+
ruan2
|
969 |
+
ruan3
|
970 |
+
rui3
|
971 |
+
rui4
|
972 |
+
run4
|
973 |
+
ruo4
|
974 |
+
s
|
975 |
+
sa1
|
976 |
+
sa2
|
977 |
+
sa3
|
978 |
+
sa4
|
979 |
+
sai1
|
980 |
+
sai4
|
981 |
+
san1
|
982 |
+
san2
|
983 |
+
san3
|
984 |
+
san4
|
985 |
+
sang1
|
986 |
+
sang3
|
987 |
+
sang4
|
988 |
+
sao1
|
989 |
+
sao2
|
990 |
+
sao3
|
991 |
+
sao4
|
992 |
+
se4
|
993 |
+
sen1
|
994 |
+
seng1
|
995 |
+
sha1
|
996 |
+
sha2
|
997 |
+
sha3
|
998 |
+
sha4
|
999 |
+
shai1
|
1000 |
+
shai2
|
1001 |
+
shai3
|
1002 |
+
shai4
|
1003 |
+
shan1
|
1004 |
+
shan3
|
1005 |
+
shan4
|
1006 |
+
shang
|
1007 |
+
shang1
|
1008 |
+
shang3
|
1009 |
+
shang4
|
1010 |
+
shao1
|
1011 |
+
shao2
|
1012 |
+
shao3
|
1013 |
+
shao4
|
1014 |
+
she1
|
1015 |
+
she2
|
1016 |
+
she3
|
1017 |
+
she4
|
1018 |
+
shei2
|
1019 |
+
shen1
|
1020 |
+
shen2
|
1021 |
+
shen3
|
1022 |
+
shen4
|
1023 |
+
sheng1
|
1024 |
+
sheng2
|
1025 |
+
sheng3
|
1026 |
+
sheng4
|
1027 |
+
shi
|
1028 |
+
shi1
|
1029 |
+
shi2
|
1030 |
+
shi3
|
1031 |
+
shi4
|
1032 |
+
shou1
|
1033 |
+
shou2
|
1034 |
+
shou3
|
1035 |
+
shou4
|
1036 |
+
shu1
|
1037 |
+
shu2
|
1038 |
+
shu3
|
1039 |
+
shu4
|
1040 |
+
shua1
|
1041 |
+
shua2
|
1042 |
+
shua3
|
1043 |
+
shua4
|
1044 |
+
shuai1
|
1045 |
+
shuai3
|
1046 |
+
shuai4
|
1047 |
+
shuan1
|
1048 |
+
shuan4
|
1049 |
+
shuang1
|
1050 |
+
shuang3
|
1051 |
+
shui2
|
1052 |
+
shui3
|
1053 |
+
shui4
|
1054 |
+
shun3
|
1055 |
+
shun4
|
1056 |
+
shuo1
|
1057 |
+
shuo4
|
1058 |
+
si1
|
1059 |
+
si2
|
1060 |
+
si3
|
1061 |
+
si4
|
1062 |
+
song1
|
1063 |
+
song3
|
1064 |
+
song4
|
1065 |
+
sou1
|
1066 |
+
sou3
|
1067 |
+
sou4
|
1068 |
+
su1
|
1069 |
+
su2
|
1070 |
+
su4
|
1071 |
+
suan1
|
1072 |
+
suan4
|
1073 |
+
sui1
|
1074 |
+
sui2
|
1075 |
+
sui3
|
1076 |
+
sui4
|
1077 |
+
sun1
|
1078 |
+
sun3
|
1079 |
+
suo
|
1080 |
+
suo1
|
1081 |
+
suo2
|
1082 |
+
suo3
|
1083 |
+
t
|
1084 |
+
ta1
|
1085 |
+
ta2
|
1086 |
+
ta3
|
1087 |
+
ta4
|
1088 |
+
tai1
|
1089 |
+
tai2
|
1090 |
+
tai4
|
1091 |
+
tan1
|
1092 |
+
tan2
|
1093 |
+
tan3
|
1094 |
+
tan4
|
1095 |
+
tang1
|
1096 |
+
tang2
|
1097 |
+
tang3
|
1098 |
+
tang4
|
1099 |
+
tao1
|
1100 |
+
tao2
|
1101 |
+
tao3
|
1102 |
+
tao4
|
1103 |
+
te4
|
1104 |
+
teng2
|
1105 |
+
ti1
|
1106 |
+
ti2
|
1107 |
+
ti3
|
1108 |
+
ti4
|
1109 |
+
tian1
|
1110 |
+
tian2
|
1111 |
+
tian3
|
1112 |
+
tiao1
|
1113 |
+
tiao2
|
1114 |
+
tiao3
|
1115 |
+
tiao4
|
1116 |
+
tie1
|
1117 |
+
tie2
|
1118 |
+
tie3
|
1119 |
+
tie4
|
1120 |
+
ting1
|
1121 |
+
ting2
|
1122 |
+
ting3
|
1123 |
+
tong1
|
1124 |
+
tong2
|
1125 |
+
tong3
|
1126 |
+
tong4
|
1127 |
+
tou
|
1128 |
+
tou1
|
1129 |
+
tou2
|
1130 |
+
tou4
|
1131 |
+
tu1
|
1132 |
+
tu2
|
1133 |
+
tu3
|
1134 |
+
tu4
|
1135 |
+
tuan1
|
1136 |
+
tuan2
|
1137 |
+
tui1
|
1138 |
+
tui2
|
1139 |
+
tui3
|
1140 |
+
tui4
|
1141 |
+
tun1
|
1142 |
+
tun2
|
1143 |
+
tun4
|
1144 |
+
tuo1
|
1145 |
+
tuo2
|
1146 |
+
tuo3
|
1147 |
+
tuo4
|
1148 |
+
u
|
1149 |
+
v
|
1150 |
+
w
|
1151 |
+
wa
|
1152 |
+
wa1
|
1153 |
+
wa2
|
1154 |
+
wa3
|
1155 |
+
wa4
|
1156 |
+
wai1
|
1157 |
+
wai3
|
1158 |
+
wai4
|
1159 |
+
wan1
|
1160 |
+
wan2
|
1161 |
+
wan3
|
1162 |
+
wan4
|
1163 |
+
wang1
|
1164 |
+
wang2
|
1165 |
+
wang3
|
1166 |
+
wang4
|
1167 |
+
wei1
|
1168 |
+
wei2
|
1169 |
+
wei3
|
1170 |
+
wei4
|
1171 |
+
wen1
|
1172 |
+
wen2
|
1173 |
+
wen3
|
1174 |
+
wen4
|
1175 |
+
weng1
|
1176 |
+
weng4
|
1177 |
+
wo1
|
1178 |
+
wo2
|
1179 |
+
wo3
|
1180 |
+
wo4
|
1181 |
+
wu1
|
1182 |
+
wu2
|
1183 |
+
wu3
|
1184 |
+
wu4
|
1185 |
+
x
|
1186 |
+
xi1
|
1187 |
+
xi2
|
1188 |
+
xi3
|
1189 |
+
xi4
|
1190 |
+
xia1
|
1191 |
+
xia2
|
1192 |
+
xia4
|
1193 |
+
xian1
|
1194 |
+
xian2
|
1195 |
+
xian3
|
1196 |
+
xian4
|
1197 |
+
xiang1
|
1198 |
+
xiang2
|
1199 |
+
xiang3
|
1200 |
+
xiang4
|
1201 |
+
xiao1
|
1202 |
+
xiao2
|
1203 |
+
xiao3
|
1204 |
+
xiao4
|
1205 |
+
xie1
|
1206 |
+
xie2
|
1207 |
+
xie3
|
1208 |
+
xie4
|
1209 |
+
xin1
|
1210 |
+
xin2
|
1211 |
+
xin4
|
1212 |
+
xing1
|
1213 |
+
xing2
|
1214 |
+
xing3
|
1215 |
+
xing4
|
1216 |
+
xiong1
|
1217 |
+
xiong2
|
1218 |
+
xiu1
|
1219 |
+
xiu3
|
1220 |
+
xiu4
|
1221 |
+
xu
|
1222 |
+
xu1
|
1223 |
+
xu2
|
1224 |
+
xu3
|
1225 |
+
xu4
|
1226 |
+
xuan1
|
1227 |
+
xuan2
|
1228 |
+
xuan3
|
1229 |
+
xuan4
|
1230 |
+
xue1
|
1231 |
+
xue2
|
1232 |
+
xue3
|
1233 |
+
xue4
|
1234 |
+
xun1
|
1235 |
+
xun2
|
1236 |
+
xun4
|
1237 |
+
y
|
1238 |
+
ya
|
1239 |
+
ya1
|
1240 |
+
ya2
|
1241 |
+
ya3
|
1242 |
+
ya4
|
1243 |
+
yan1
|
1244 |
+
yan2
|
1245 |
+
yan3
|
1246 |
+
yan4
|
1247 |
+
yang1
|
1248 |
+
yang2
|
1249 |
+
yang3
|
1250 |
+
yang4
|
1251 |
+
yao1
|
1252 |
+
yao2
|
1253 |
+
yao3
|
1254 |
+
yao4
|
1255 |
+
ye1
|
1256 |
+
ye2
|
1257 |
+
ye3
|
1258 |
+
ye4
|
1259 |
+
yi
|
1260 |
+
yi1
|
1261 |
+
yi2
|
1262 |
+
yi3
|
1263 |
+
yi4
|
1264 |
+
yin1
|
1265 |
+
yin2
|
1266 |
+
yin3
|
1267 |
+
yin4
|
1268 |
+
ying1
|
1269 |
+
ying2
|
1270 |
+
ying3
|
1271 |
+
ying4
|
1272 |
+
yo1
|
1273 |
+
yong1
|
1274 |
+
yong2
|
1275 |
+
yong3
|
1276 |
+
yong4
|
1277 |
+
you1
|
1278 |
+
you2
|
1279 |
+
you3
|
1280 |
+
you4
|
1281 |
+
yu1
|
1282 |
+
yu2
|
1283 |
+
yu3
|
1284 |
+
yu4
|
1285 |
+
yuan1
|
1286 |
+
yuan2
|
1287 |
+
yuan3
|
1288 |
+
yuan4
|
1289 |
+
yue1
|
1290 |
+
yue4
|
1291 |
+
yun1
|
1292 |
+
yun2
|
1293 |
+
yun3
|
1294 |
+
yun4
|
1295 |
+
z
|
1296 |
+
za1
|
1297 |
+
za2
|
1298 |
+
za3
|
1299 |
+
zai1
|
1300 |
+
zai3
|
1301 |
+
zai4
|
1302 |
+
zan1
|
1303 |
+
zan2
|
1304 |
+
zan3
|
1305 |
+
zan4
|
1306 |
+
zang1
|
1307 |
+
zang4
|
1308 |
+
zao1
|
1309 |
+
zao2
|
1310 |
+
zao3
|
1311 |
+
zao4
|
1312 |
+
ze2
|
1313 |
+
ze4
|
1314 |
+
zei2
|
1315 |
+
zen3
|
1316 |
+
zeng1
|
1317 |
+
zeng4
|
1318 |
+
zha1
|
1319 |
+
zha2
|
1320 |
+
zha3
|
1321 |
+
zha4
|
1322 |
+
zhai1
|
1323 |
+
zhai2
|
1324 |
+
zhai3
|
1325 |
+
zhai4
|
1326 |
+
zhan1
|
1327 |
+
zhan2
|
1328 |
+
zhan3
|
1329 |
+
zhan4
|
1330 |
+
zhang1
|
1331 |
+
zhang2
|
1332 |
+
zhang3
|
1333 |
+
zhang4
|
1334 |
+
zhao1
|
1335 |
+
zhao2
|
1336 |
+
zhao3
|
1337 |
+
zhao4
|
1338 |
+
zhe
|
1339 |
+
zhe1
|
1340 |
+
zhe2
|
1341 |
+
zhe3
|
1342 |
+
zhe4
|
1343 |
+
zhen1
|
1344 |
+
zhen2
|
1345 |
+
zhen3
|
1346 |
+
zhen4
|
1347 |
+
zheng1
|
1348 |
+
zheng2
|
1349 |
+
zheng3
|
1350 |
+
zheng4
|
1351 |
+
zhi1
|
1352 |
+
zhi2
|
1353 |
+
zhi3
|
1354 |
+
zhi4
|
1355 |
+
zhong1
|
1356 |
+
zhong2
|
1357 |
+
zhong3
|
1358 |
+
zhong4
|
1359 |
+
zhou1
|
1360 |
+
zhou2
|
1361 |
+
zhou3
|
1362 |
+
zhou4
|
1363 |
+
zhu1
|
1364 |
+
zhu2
|
1365 |
+
zhu3
|
1366 |
+
zhu4
|
1367 |
+
zhua1
|
1368 |
+
zhua2
|
1369 |
+
zhua3
|
1370 |
+
zhuai1
|
1371 |
+
zhuai3
|
1372 |
+
zhuai4
|
1373 |
+
zhuan1
|
1374 |
+
zhuan2
|
1375 |
+
zhuan3
|
1376 |
+
zhuan4
|
1377 |
+
zhuang1
|
1378 |
+
zhuang4
|
1379 |
+
zhui1
|
1380 |
+
zhui4
|
1381 |
+
zhun1
|
1382 |
+
zhun2
|
1383 |
+
zhun3
|
1384 |
+
zhuo1
|
1385 |
+
zhuo2
|
1386 |
+
zi
|
1387 |
+
zi1
|
1388 |
+
zi2
|
1389 |
+
zi3
|
1390 |
+
zi4
|
1391 |
+
zong1
|
1392 |
+
zong2
|
1393 |
+
zong3
|
1394 |
+
zong4
|
1395 |
+
zou1
|
1396 |
+
zou2
|
1397 |
+
zou3
|
1398 |
+
zou4
|
1399 |
+
zu1
|
1400 |
+
zu2
|
1401 |
+
zu3
|
1402 |
+
zuan1
|
1403 |
+
zuan3
|
1404 |
+
zuan4
|
1405 |
+
zui2
|
1406 |
+
zui3
|
1407 |
+
zui4
|
1408 |
+
zun1
|
1409 |
+
zuo
|
1410 |
+
zuo1
|
1411 |
+
zuo2
|
1412 |
+
zuo3
|
1413 |
+
zuo4
|
1414 |
+
{
|
1415 |
+
~
|
1416 |
+
¡
|
1417 |
+
¢
|
1418 |
+
£
|
1419 |
+
¥
|
1420 |
+
§
|
1421 |
+
¨
|
1422 |
+
©
|
1423 |
+
«
|
1424 |
+
®
|
1425 |
+
¯
|
1426 |
+
°
|
1427 |
+
±
|
1428 |
+
²
|
1429 |
+
³
|
1430 |
+
´
|
1431 |
+
µ
|
1432 |
+
·
|
1433 |
+
¹
|
1434 |
+
º
|
1435 |
+
»
|
1436 |
+
¼
|
1437 |
+
½
|
1438 |
+
¾
|
1439 |
+
¿
|
1440 |
+
À
|
1441 |
+
Á
|
1442 |
+
Â
|
1443 |
+
Ã
|
1444 |
+
Ä
|
1445 |
+
Å
|
1446 |
+
Æ
|
1447 |
+
Ç
|
1448 |
+
È
|
1449 |
+
É
|
1450 |
+
Ê
|
1451 |
+
Í
|
1452 |
+
Î
|
1453 |
+
Ñ
|
1454 |
+
Ó
|
1455 |
+
Ö
|
1456 |
+
×
|
1457 |
+
Ø
|
1458 |
+
Ú
|
1459 |
+
Ü
|
1460 |
+
Ý
|
1461 |
+
Þ
|
1462 |
+
ß
|
1463 |
+
à
|
1464 |
+
á
|
1465 |
+
â
|
1466 |
+
ã
|
1467 |
+
ä
|
1468 |
+
å
|
1469 |
+
æ
|
1470 |
+
ç
|
1471 |
+
è
|
1472 |
+
é
|
1473 |
+
ê
|
1474 |
+
ë
|
1475 |
+
ì
|
1476 |
+
í
|
1477 |
+
î
|
1478 |
+
ï
|
1479 |
+
ð
|
1480 |
+
ñ
|
1481 |
+
ò
|
1482 |
+
ó
|
1483 |
+
ô
|
1484 |
+
õ
|
1485 |
+
ö
|
1486 |
+
ø
|
1487 |
+
ù
|
1488 |
+
ú
|
1489 |
+
û
|
1490 |
+
ü
|
1491 |
+
ý
|
1492 |
+
Ā
|
1493 |
+
ā
|
1494 |
+
ă
|
1495 |
+
ą
|
1496 |
+
ć
|
1497 |
+
Č
|
1498 |
+
č
|
1499 |
+
Đ
|
1500 |
+
đ
|
1501 |
+
ē
|
1502 |
+
ė
|
1503 |
+
ę
|
1504 |
+
ě
|
1505 |
+
ĝ
|
1506 |
+
ğ
|
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1586 |
+
Π
|
1587 |
+
Σ
|
1588 |
+
Τ
|
1589 |
+
Φ
|
1590 |
+
Χ
|
1591 |
+
Ψ
|
1592 |
+
Ω
|
1593 |
+
ά
|
1594 |
+
έ
|
1595 |
+
ή
|
1596 |
+
ί
|
1597 |
+
α
|
1598 |
+
β
|
1599 |
+
γ
|
1600 |
+
δ
|
1601 |
+
ε
|
1602 |
+
ζ
|
1603 |
+
η
|
1604 |
+
θ
|
1605 |
+
ι
|
1606 |
+
κ
|
1607 |
+
λ
|
1608 |
+
μ
|
1609 |
+
ν
|
1610 |
+
ξ
|
1611 |
+
ο
|
1612 |
+
π
|
1613 |
+
ρ
|
1614 |
+
ς
|
1615 |
+
σ
|
1616 |
+
τ
|
1617 |
+
υ
|
1618 |
+
φ
|
1619 |
+
χ
|
1620 |
+
ψ
|
1621 |
+
ω
|
1622 |
+
ϊ
|
1623 |
+
ό
|
1624 |
+
ύ
|
1625 |
+
ώ
|
1626 |
+
ϕ
|
1627 |
+
ϵ
|
1628 |
+
Ё
|
1629 |
+
А
|
1630 |
+
Б
|
1631 |
+
В
|
1632 |
+
Г
|
1633 |
+
Д
|
1634 |
+
Е
|
1635 |
+
Ж
|
1636 |
+
З
|
1637 |
+
И
|
1638 |
+
Й
|
1639 |
+
К
|
1640 |
+
Л
|
1641 |
+
М
|
1642 |
+
Н
|
1643 |
+
О
|
1644 |
+
П
|
1645 |
+
Р
|
1646 |
+
С
|
1647 |
+
Т
|
1648 |
+
У
|
1649 |
+
Ф
|
1650 |
+
Х
|
1651 |
+
Ц
|
1652 |
+
Ч
|
1653 |
+
Ш
|
1654 |
+
Щ
|
1655 |
+
Ы
|
1656 |
+
Ь
|
1657 |
+
Э
|
1658 |
+
Ю
|
1659 |
+
Я
|
1660 |
+
а
|
1661 |
+
б
|
1662 |
+
в
|
1663 |
+
г
|
1664 |
+
д
|
1665 |
+
е
|
1666 |
+
ж
|
1667 |
+
з
|
1668 |
+
и
|
1669 |
+
й
|
1670 |
+
к
|
1671 |
+
л
|
1672 |
+
м
|
1673 |
+
н
|
1674 |
+
о
|
1675 |
+
п
|
1676 |
+
р
|
1677 |
+
с
|
1678 |
+
т
|
1679 |
+
у
|
1680 |
+
ф
|
1681 |
+
х
|
1682 |
+
ц
|
1683 |
+
ч
|
1684 |
+
ш
|
1685 |
+
щ
|
1686 |
+
ъ
|
1687 |
+
ы
|
1688 |
+
ь
|
1689 |
+
э
|
1690 |
+
ю
|
1691 |
+
я
|
1692 |
+
ё
|
1693 |
+
і
|
1694 |
+
ְ
|
1695 |
+
ִ
|
1696 |
+
ֵ
|
1697 |
+
ֶ
|
1698 |
+
ַ
|
1699 |
+
ָ
|
1700 |
+
ֹ
|
1701 |
+
ּ
|
1702 |
+
־
|
1703 |
+
ׁ
|
1704 |
+
א
|
1705 |
+
ב
|
1706 |
+
ג
|
1707 |
+
ד
|
1708 |
+
ה
|
1709 |
+
ו
|
1710 |
+
ז
|
1711 |
+
ח
|
1712 |
+
ט
|
1713 |
+
י
|
1714 |
+
כ
|
1715 |
+
ל
|
1716 |
+
ם
|
1717 |
+
מ
|
1718 |
+
ן
|
1719 |
+
נ
|
1720 |
+
ס
|
1721 |
+
ע
|
1722 |
+
פ
|
1723 |
+
ק
|
1724 |
+
ר
|
1725 |
+
ש
|
1726 |
+
ת
|
1727 |
+
أ
|
1728 |
+
ب
|
1729 |
+
ة
|
1730 |
+
ت
|
1731 |
+
ج
|
1732 |
+
ح
|
1733 |
+
د
|
1734 |
+
ر
|
1735 |
+
ز
|
1736 |
+
س
|
1737 |
+
ص
|
1738 |
+
ط
|
1739 |
+
ع
|
1740 |
+
ق
|
1741 |
+
ك
|
1742 |
+
ل
|
1743 |
+
م
|
1744 |
+
ن
|
1745 |
+
ه
|
1746 |
+
و
|
1747 |
+
ي
|
1748 |
+
َ
|
1749 |
+
ُ
|
1750 |
+
ِ
|
1751 |
+
ْ
|
1752 |
+
ก
|
1753 |
+
ข
|
1754 |
+
ง
|
1755 |
+
จ
|
1756 |
+
ต
|
1757 |
+
ท
|
1758 |
+
น
|
1759 |
+
ป
|
1760 |
+
ย
|
1761 |
+
ร
|
1762 |
+
ว
|
1763 |
+
ส
|
1764 |
+
ห
|
1765 |
+
อ
|
1766 |
+
ฮ
|
1767 |
+
ั
|
1768 |
+
า
|
1769 |
+
ี
|
1770 |
+
ึ
|
1771 |
+
โ
|
1772 |
+
ใ
|
1773 |
+
ไ
|
1774 |
+
่
|
1775 |
+
้
|
1776 |
+
์
|
1777 |
+
ḍ
|
1778 |
+
Ḥ
|
1779 |
+
ḥ
|
1780 |
+
ṁ
|
1781 |
+
ṃ
|
1782 |
+
ṅ
|
1783 |
+
ṇ
|
1784 |
+
Ṛ
|
1785 |
+
ṛ
|
1786 |
+
Ṣ
|
1787 |
+
ṣ
|
1788 |
+
Ṭ
|
1789 |
+
ṭ
|
1790 |
+
ạ
|
1791 |
+
ả
|
1792 |
+
Ấ
|
1793 |
+
ấ
|
1794 |
+
ầ
|
1795 |
+
ậ
|
1796 |
+
ắ
|
1797 |
+
ằ
|
1798 |
+
ẻ
|
1799 |
+
ẽ
|
1800 |
+
ế
|
1801 |
+
ề
|
1802 |
+
ể
|
1803 |
+
ễ
|
1804 |
+
ệ
|
1805 |
+
ị
|
1806 |
+
ọ
|
1807 |
+
ỏ
|
1808 |
+
ố
|
1809 |
+
ồ
|
1810 |
+
ộ
|
1811 |
+
ớ
|
1812 |
+
ờ
|
1813 |
+
ở
|
1814 |
+
ụ
|
1815 |
+
ủ
|
1816 |
+
ứ
|
1817 |
+
ữ
|
1818 |
+
ἀ
|
1819 |
+
ἁ
|
1820 |
+
Ἀ
|
1821 |
+
ἐ
|
1822 |
+
ἔ
|
1823 |
+
ἰ
|
1824 |
+
ἱ
|
1825 |
+
ὀ
|
1826 |
+
ὁ
|
1827 |
+
ὐ
|
1828 |
+
ὲ
|
1829 |
+
ὸ
|
1830 |
+
ᾶ
|
1831 |
+
᾽
|
1832 |
+
ῆ
|
1833 |
+
ῇ
|
1834 |
+
ῶ
|
1835 |
+
|
1836 |
+
‑
|
1837 |
+
‒
|
1838 |
+
–
|
1839 |
+
—
|
1840 |
+
―
|
1841 |
+
‖
|
1842 |
+
†
|
1843 |
+
‡
|
1844 |
+
•
|
1845 |
+
…
|
1846 |
+
‧
|
1847 |
+
|
1848 |
+
′
|
1849 |
+
″
|
1850 |
+
⁄
|
1851 |
+
|
1852 |
+
⁰
|
1853 |
+
⁴
|
1854 |
+
⁵
|
1855 |
+
⁶
|
1856 |
+
⁷
|
1857 |
+
⁸
|
1858 |
+
⁹
|
1859 |
+
₁
|
1860 |
+
₂
|
1861 |
+
₃
|
1862 |
+
€
|
1863 |
+
₱
|
1864 |
+
₹
|
1865 |
+
₽
|
1866 |
+
℃
|
1867 |
+
ℏ
|
1868 |
+
ℓ
|
1869 |
+
№
|
1870 |
+
ℝ
|
1871 |
+
™
|
1872 |
+
⅓
|
1873 |
+
⅔
|
1874 |
+
⅛
|
1875 |
+
→
|
1876 |
+
∂
|
1877 |
+
∈
|
1878 |
+
∑
|
1879 |
+
−
|
1880 |
+
∗
|
1881 |
+
√
|
1882 |
+
∞
|
1883 |
+
∫
|
1884 |
+
≈
|
1885 |
+
≠
|
1886 |
+
≡
|
1887 |
+
≤
|
1888 |
+
≥
|
1889 |
+
⋅
|
1890 |
+
⋯
|
1891 |
+
█
|
1892 |
+
♪
|
1893 |
+
⟨
|
1894 |
+
⟩
|
1895 |
+
、
|
1896 |
+
。
|
1897 |
+
《
|
1898 |
+
》
|
1899 |
+
「
|
1900 |
+
」
|
1901 |
+
【
|
1902 |
+
】
|
1903 |
+
あ
|
1904 |
+
う
|
1905 |
+
え
|
1906 |
+
お
|
1907 |
+
か
|
1908 |
+
が
|
1909 |
+
き
|
1910 |
+
ぎ
|
1911 |
+
く
|
1912 |
+
ぐ
|
1913 |
+
け
|
1914 |
+
げ
|
1915 |
+
こ
|
1916 |
+
ご
|
1917 |
+
さ
|
1918 |
+
し
|
1919 |
+
じ
|
1920 |
+
す
|
1921 |
+
ず
|
1922 |
+
せ
|
1923 |
+
ぜ
|
1924 |
+
そ
|
1925 |
+
ぞ
|
1926 |
+
た
|
1927 |
+
だ
|
1928 |
+
ち
|
1929 |
+
っ
|
1930 |
+
つ
|
1931 |
+
で
|
1932 |
+
と
|
1933 |
+
ど
|
1934 |
+
な
|
1935 |
+
に
|
1936 |
+
ね
|
1937 |
+
の
|
1938 |
+
は
|
1939 |
+
ば
|
1940 |
+
ひ
|
1941 |
+
ぶ
|
1942 |
+
へ
|
1943 |
+
べ
|
1944 |
+
ま
|
1945 |
+
み
|
1946 |
+
む
|
1947 |
+
め
|
1948 |
+
も
|
1949 |
+
ゃ
|
1950 |
+
や
|
1951 |
+
ゆ
|
1952 |
+
ょ
|
1953 |
+
よ
|
1954 |
+
ら
|
1955 |
+
り
|
1956 |
+
る
|
1957 |
+
れ
|
1958 |
+
ろ
|
1959 |
+
わ
|
1960 |
+
を
|
1961 |
+
ん
|
1962 |
+
ァ
|
1963 |
+
ア
|
1964 |
+
ィ
|
1965 |
+
イ
|
1966 |
+
ウ
|
1967 |
+
ェ
|
1968 |
+
エ
|
1969 |
+
オ
|
1970 |
+
カ
|
1971 |
+
ガ
|
1972 |
+
キ
|
1973 |
+
ク
|
1974 |
+
ケ
|
1975 |
+
ゲ
|
1976 |
+
コ
|
1977 |
+
ゴ
|
1978 |
+
サ
|
1979 |
+
ザ
|
1980 |
+
シ
|
1981 |
+
ジ
|
1982 |
+
ス
|
1983 |
+
ズ
|
1984 |
+
セ
|
1985 |
+
ゾ
|
1986 |
+
タ
|
1987 |
+
ダ
|
1988 |
+
チ
|
1989 |
+
ッ
|
1990 |
+
ツ
|
1991 |
+
テ
|
1992 |
+
デ
|
1993 |
+
ト
|
1994 |
+
ド
|
1995 |
+
ナ
|
1996 |
+
ニ
|
1997 |
+
ネ
|
1998 |
+
ノ
|
1999 |
+
バ
|
2000 |
+
パ
|
2001 |
+
ビ
|
2002 |
+
ピ
|
2003 |
+
フ
|
2004 |
+
プ
|
2005 |
+
ヘ
|
2006 |
+
ベ
|
2007 |
+
ペ
|
2008 |
+
ホ
|
2009 |
+
ボ
|
2010 |
+
ポ
|
2011 |
+
マ
|
2012 |
+
ミ
|
2013 |
+
ム
|
2014 |
+
メ
|
2015 |
+
モ
|
2016 |
+
ャ
|
2017 |
+
ヤ
|
2018 |
+
ュ
|
2019 |
+
ユ
|
2020 |
+
ョ
|
2021 |
+
ヨ
|
2022 |
+
ラ
|
2023 |
+
リ
|
2024 |
+
ル
|
2025 |
+
レ
|
2026 |
+
ロ
|
2027 |
+
ワ
|
2028 |
+
ン
|
2029 |
+
・
|
2030 |
+
ー
|
2031 |
+
ㄋ
|
2032 |
+
ㄍ
|
2033 |
+
ㄎ
|
2034 |
+
ㄏ
|
2035 |
+
ㄓ
|
2036 |
+
ㄕ
|
2037 |
+
ㄚ
|
2038 |
+
ㄜ
|
2039 |
+
ㄟ
|
2040 |
+
ㄤ
|
2041 |
+
ㄥ
|
2042 |
+
ㄧ
|
2043 |
+
ㄱ
|
2044 |
+
ㄴ
|
2045 |
+
ㄷ
|
2046 |
+
ㄹ
|
2047 |
+
ㅁ
|
2048 |
+
ㅂ
|
2049 |
+
ㅅ
|
2050 |
+
ㅈ
|
2051 |
+
ㅍ
|
2052 |
+
ㅎ
|
2053 |
+
ㅏ
|
2054 |
+
ㅓ
|
2055 |
+
ㅗ
|
2056 |
+
ㅜ
|
2057 |
+
ㅡ
|
2058 |
+
ㅣ
|
2059 |
+
㗎
|
2060 |
+
가
|
2061 |
+
각
|
2062 |
+
간
|
2063 |
+
갈
|
2064 |
+
감
|
2065 |
+
갑
|
2066 |
+
갓
|
2067 |
+
갔
|
2068 |
+
강
|
2069 |
+
같
|
2070 |
+
개
|
2071 |
+
거
|
2072 |
+
건
|
2073 |
+
걸
|
2074 |
+
겁
|
2075 |
+
것
|
2076 |
+
겉
|
2077 |
+
게
|
2078 |
+
겠
|
2079 |
+
겨
|
2080 |
+
결
|
2081 |
+
겼
|
2082 |
+
경
|
2083 |
+
계
|
2084 |
+
고
|
2085 |
+
곤
|
2086 |
+
골
|
2087 |
+
곱
|
2088 |
+
공
|
2089 |
+
과
|
2090 |
+
관
|
2091 |
+
광
|
2092 |
+
교
|
2093 |
+
구
|
2094 |
+
국
|
2095 |
+
굴
|
2096 |
+
귀
|
2097 |
+
귄
|
2098 |
+
그
|
2099 |
+
근
|
2100 |
+
글
|
2101 |
+
금
|
2102 |
+
기
|
2103 |
+
긴
|
2104 |
+
길
|
2105 |
+
까
|
2106 |
+
깍
|
2107 |
+
깔
|
2108 |
+
깜
|
2109 |
+
깨
|
2110 |
+
께
|
2111 |
+
꼬
|
2112 |
+
꼭
|
2113 |
+
꽃
|
2114 |
+
꾸
|
2115 |
+
꿔
|
2116 |
+
끔
|
2117 |
+
끗
|
2118 |
+
끝
|
2119 |
+
끼
|
2120 |
+
나
|
2121 |
+
난
|
2122 |
+
날
|
2123 |
+
남
|
2124 |
+
납
|
2125 |
+
내
|
2126 |
+
냐
|
2127 |
+
냥
|
2128 |
+
너
|
2129 |
+
넘
|
2130 |
+
넣
|
2131 |
+
네
|
2132 |
+
녁
|
2133 |
+
년
|
2134 |
+
녕
|
2135 |
+
노
|
2136 |
+
녹
|
2137 |
+
놀
|
2138 |
+
누
|
2139 |
+
눈
|
2140 |
+
느
|
2141 |
+
는
|
2142 |
+
늘
|
2143 |
+
니
|
2144 |
+
님
|
2145 |
+
닙
|
2146 |
+
다
|
2147 |
+
닥
|
2148 |
+
단
|
2149 |
+
달
|
2150 |
+
닭
|
2151 |
+
당
|
2152 |
+
대
|
2153 |
+
더
|
2154 |
+
덕
|
2155 |
+
던
|
2156 |
+
덥
|
2157 |
+
데
|
2158 |
+
도
|
2159 |
+
독
|
2160 |
+
동
|
2161 |
+
돼
|
2162 |
+
됐
|
2163 |
+
되
|
2164 |
+
된
|
2165 |
+
될
|
2166 |
+
두
|
2167 |
+
둑
|
2168 |
+
둥
|
2169 |
+
드
|
2170 |
+
들
|
2171 |
+
등
|
2172 |
+
디
|
2173 |
+
따
|
2174 |
+
딱
|
2175 |
+
딸
|
2176 |
+
땅
|
2177 |
+
때
|
2178 |
+
떤
|
2179 |
+
떨
|
2180 |
+
떻
|
2181 |
+
또
|
2182 |
+
똑
|
2183 |
+
뚱
|
2184 |
+
뛰
|
2185 |
+
뜻
|
2186 |
+
띠
|
2187 |
+
라
|
2188 |
+
락
|
2189 |
+
란
|
2190 |
+
람
|
2191 |
+
랍
|
2192 |
+
랑
|
2193 |
+
래
|
2194 |
+
랜
|
2195 |
+
러
|
2196 |
+
런
|
2197 |
+
럼
|
2198 |
+
렇
|
2199 |
+
레
|
2200 |
+
려
|
2201 |
+
력
|
2202 |
+
렵
|
2203 |
+
렸
|
2204 |
+
로
|
2205 |
+
록
|
2206 |
+
롬
|
2207 |
+
루
|
2208 |
+
르
|
2209 |
+
른
|
2210 |
+
를
|
2211 |
+
름
|
2212 |
+
릉
|
2213 |
+
리
|
2214 |
+
릴
|
2215 |
+
림
|
2216 |
+
마
|
2217 |
+
막
|
2218 |
+
만
|
2219 |
+
많
|
2220 |
+
말
|
2221 |
+
맑
|
2222 |
+
맙
|
2223 |
+
맛
|
2224 |
+
매
|
2225 |
+
머
|
2226 |
+
먹
|
2227 |
+
멍
|
2228 |
+
메
|
2229 |
+
면
|
2230 |
+
명
|
2231 |
+
몇
|
2232 |
+
모
|
2233 |
+
목
|
2234 |
+
몸
|
2235 |
+
못
|
2236 |
+
무
|
2237 |
+
문
|
2238 |
+
물
|
2239 |
+
뭐
|
2240 |
+
뭘
|
2241 |
+
미
|
2242 |
+
민
|
2243 |
+
밌
|
2244 |
+
밑
|
2245 |
+
바
|
2246 |
+
박
|
2247 |
+
밖
|
2248 |
+
반
|
2249 |
+
받
|
2250 |
+
발
|
2251 |
+
밤
|
2252 |
+
밥
|
2253 |
+
방
|
2254 |
+
배
|
2255 |
+
백
|
2256 |
+
밸
|
2257 |
+
뱀
|
2258 |
+
버
|
2259 |
+
번
|
2260 |
+
벌
|
2261 |
+
벚
|
2262 |
+
베
|
2263 |
+
벼
|
2264 |
+
벽
|
2265 |
+
별
|
2266 |
+
병
|
2267 |
+
보
|
2268 |
+
복
|
2269 |
+
본
|
2270 |
+
볼
|
2271 |
+
봐
|
2272 |
+
봤
|
2273 |
+
부
|
2274 |
+
분
|
2275 |
+
불
|
2276 |
+
비
|
2277 |
+
빔
|
2278 |
+
빛
|
2279 |
+
빠
|
2280 |
+
빨
|
2281 |
+
뼈
|
2282 |
+
뽀
|
2283 |
+
뿅
|
2284 |
+
쁘
|
2285 |
+
사
|
2286 |
+
산
|
2287 |
+
살
|
2288 |
+
삼
|
2289 |
+
샀
|
2290 |
+
상
|
2291 |
+
새
|
2292 |
+
색
|
2293 |
+
생
|
2294 |
+
서
|
2295 |
+
선
|
2296 |
+
설
|
2297 |
+
섭
|
2298 |
+
섰
|
2299 |
+
성
|
2300 |
+
세
|
2301 |
+
셔
|
2302 |
+
션
|
2303 |
+
셨
|
2304 |
+
소
|
2305 |
+
속
|
2306 |
+
손
|
2307 |
+
송
|
2308 |
+
수
|
2309 |
+
숙
|
2310 |
+
순
|
2311 |
+
술
|
2312 |
+
숫
|
2313 |
+
숭
|
2314 |
+
숲
|
2315 |
+
쉬
|
2316 |
+
쉽
|
2317 |
+
스
|
2318 |
+
슨
|
2319 |
+
습
|
2320 |
+
슷
|
2321 |
+
시
|
2322 |
+
식
|
2323 |
+
신
|
2324 |
+
실
|
2325 |
+
싫
|
2326 |
+
심
|
2327 |
+
십
|
2328 |
+
싶
|
2329 |
+
싸
|
2330 |
+
써
|
2331 |
+
쓰
|
2332 |
+
쓴
|
2333 |
+
씌
|
2334 |
+
씨
|
2335 |
+
씩
|
2336 |
+
씬
|
2337 |
+
아
|
2338 |
+
악
|
2339 |
+
안
|
2340 |
+
않
|
2341 |
+
알
|
2342 |
+
야
|
2343 |
+
약
|
2344 |
+
얀
|
2345 |
+
양
|
2346 |
+
얘
|
2347 |
+
어
|
2348 |
+
언
|
2349 |
+
얼
|
2350 |
+
엄
|
2351 |
+
업
|
2352 |
+
없
|
2353 |
+
었
|
2354 |
+
엉
|
2355 |
+
에
|
2356 |
+
여
|
2357 |
+
역
|
2358 |
+
연
|
2359 |
+
염
|
2360 |
+
엽
|
2361 |
+
영
|
2362 |
+
옆
|
2363 |
+
예
|
2364 |
+
옛
|
2365 |
+
오
|
2366 |
+
온
|
2367 |
+
올
|
2368 |
+
옷
|
2369 |
+
옹
|
2370 |
+
와
|
2371 |
+
왔
|
2372 |
+
왜
|
2373 |
+
요
|
2374 |
+
욕
|
2375 |
+
용
|
2376 |
+
우
|
2377 |
+
운
|
2378 |
+
울
|
2379 |
+
웃
|
2380 |
+
워
|
2381 |
+
원
|
2382 |
+
월
|
2383 |
+
웠
|
2384 |
+
위
|
2385 |
+
윙
|
2386 |
+
유
|
2387 |
+
육
|
2388 |
+
윤
|
2389 |
+
으
|
2390 |
+
은
|
2391 |
+
을
|
2392 |
+
음
|
2393 |
+
응
|
2394 |
+
의
|
2395 |
+
이
|
2396 |
+
익
|
2397 |
+
인
|
2398 |
+
일
|
2399 |
+
읽
|
2400 |
+
임
|
2401 |
+
입
|
2402 |
+
있
|
2403 |
+
자
|
2404 |
+
작
|
2405 |
+
잔
|
2406 |
+
잖
|
2407 |
+
잘
|
2408 |
+
잡
|
2409 |
+
잤
|
2410 |
+
장
|
2411 |
+
재
|
2412 |
+
저
|
2413 |
+
전
|
2414 |
+
점
|
2415 |
+
정
|
2416 |
+
제
|
2417 |
+
져
|
2418 |
+
졌
|
2419 |
+
조
|
2420 |
+
족
|
2421 |
+
좀
|
2422 |
+
종
|
2423 |
+
좋
|
2424 |
+
죠
|
2425 |
+
주
|
2426 |
+
준
|
2427 |
+
줄
|
2428 |
+
중
|
2429 |
+
줘
|
2430 |
+
즈
|
2431 |
+
즐
|
2432 |
+
즘
|
2433 |
+
지
|
2434 |
+
진
|
2435 |
+
집
|
2436 |
+
짜
|
2437 |
+
짝
|
2438 |
+
쩌
|
2439 |
+
쪼
|
2440 |
+
쪽
|
2441 |
+
쫌
|
2442 |
+
쭈
|
2443 |
+
쯔
|
2444 |
+
찌
|
2445 |
+
찍
|
2446 |
+
차
|
2447 |
+
착
|
2448 |
+
찾
|
2449 |
+
책
|
2450 |
+
처
|
2451 |
+
천
|
2452 |
+
철
|
2453 |
+
체
|
2454 |
+
쳐
|
2455 |
+
쳤
|
2456 |
+
초
|
2457 |
+
촌
|
2458 |
+
추
|
2459 |
+
출
|
2460 |
+
춤
|
2461 |
+
춥
|
2462 |
+
춰
|
2463 |
+
치
|
2464 |
+
친
|
2465 |
+
칠
|
2466 |
+
침
|
2467 |
+
칩
|
2468 |
+
칼
|
2469 |
+
커
|
2470 |
+
켓
|
2471 |
+
코
|
2472 |
+
콩
|
2473 |
+
쿠
|
2474 |
+
퀴
|
2475 |
+
크
|
2476 |
+
큰
|
2477 |
+
큽
|
2478 |
+
키
|
2479 |
+
킨
|
2480 |
+
타
|
2481 |
+
태
|
2482 |
+
터
|
2483 |
+
턴
|
2484 |
+
털
|
2485 |
+
테
|
2486 |
+
토
|
2487 |
+
통
|
2488 |
+
투
|
2489 |
+
트
|
2490 |
+
특
|
2491 |
+
튼
|
2492 |
+
틀
|
2493 |
+
티
|
2494 |
+
팀
|
2495 |
+
파
|
2496 |
+
팔
|
2497 |
+
패
|
2498 |
+
페
|
2499 |
+
펜
|
2500 |
+
펭
|
2501 |
+
평
|
2502 |
+
포
|
2503 |
+
폭
|
2504 |
+
표
|
2505 |
+
품
|
2506 |
+
풍
|
2507 |
+
프
|
2508 |
+
플
|
2509 |
+
피
|
2510 |
+
필
|
2511 |
+
하
|
2512 |
+
학
|
2513 |
+
한
|
2514 |
+
할
|
2515 |
+
함
|
2516 |
+
합
|
2517 |
+
항
|
2518 |
+
해
|
2519 |
+
햇
|
2520 |
+
했
|
2521 |
+
행
|
2522 |
+
허
|
2523 |
+
험
|
2524 |
+
형
|
2525 |
+
혜
|
2526 |
+
호
|
2527 |
+
혼
|
2528 |
+
홀
|
2529 |
+
화
|
2530 |
+
회
|
2531 |
+
획
|
2532 |
+
후
|
2533 |
+
휴
|
2534 |
+
흐
|
2535 |
+
흔
|
2536 |
+
희
|
2537 |
+
히
|
2538 |
+
힘
|
2539 |
+
ﷺ
|
2540 |
+
ﷻ
|
2541 |
+
!
|
2542 |
+
,
|
2543 |
+
?
|
2544 |
+
�
|
2545 |
+
𠮶
|
f5_tts/infer/infer_batch_parallel.py
ADDED
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import codecs
|
3 |
+
import os
|
4 |
+
import re
|
5 |
+
from pathlib import Path
|
6 |
+
|
7 |
+
import numpy as np
|
8 |
+
import soundfile as sf
|
9 |
+
import tomli
|
10 |
+
from cached_path import cached_path
|
11 |
+
import pandas as pd
|
12 |
+
from tqdm import tqdm
|
13 |
+
|
14 |
+
from f5_tts.infer.utils_infer import (
|
15 |
+
infer_process,
|
16 |
+
load_model,
|
17 |
+
load_vocoder,
|
18 |
+
preprocess_ref_audio_text,
|
19 |
+
remove_silence_for_generated_wav,
|
20 |
+
)
|
21 |
+
from f5_tts.model import DiT, UNetT
|
22 |
+
|
23 |
+
|
24 |
+
def run_batch_inference(prompt_paths, prompt_texts, texts, languages, categories, model_obj, vocoder, mel_spec_type, remove_silence, speed, output_dir):
|
25 |
+
count = 0
|
26 |
+
for ref_audio in prompt_paths:
|
27 |
+
if not isinstance(ref_audio, str) or not os.path.isfile(ref_audio):
|
28 |
+
print(f"Invalid ref_audio: {ref_audio}")
|
29 |
+
count += 1
|
30 |
+
print(count)
|
31 |
+
# raise ValueError(f"Invalid ref_audio: {ref_audio}")
|
32 |
+
|
33 |
+
for idx, (ref_audio, ref_text, text_gen, language, category) in tqdm(enumerate(zip(prompt_paths, prompt_texts, texts, languages, categories))):
|
34 |
+
voices = {"main": {"ref_audio": ref_audio, "ref_text": ref_text}}
|
35 |
+
for voice in voices:
|
36 |
+
voices[voice]["ref_audio"], voices[voice]["ref_text"] = preprocess_ref_audio_text(
|
37 |
+
voices[voice]["ref_audio"], voices[voice]["ref_text"]
|
38 |
+
)
|
39 |
+
print("Voice:", voice)
|
40 |
+
print("Ref_audio:", voices[voice]["ref_audio"])
|
41 |
+
print("Ref_text:", voices[voice]["ref_text"])
|
42 |
+
|
43 |
+
generated_audio_segments = []
|
44 |
+
reg1 = r"(?=\[\w+\])"
|
45 |
+
chunks = re.split(reg1, text_gen)
|
46 |
+
reg2 = r"\[(\w+)\]"
|
47 |
+
for text in chunks:
|
48 |
+
if not text.strip():
|
49 |
+
continue
|
50 |
+
match = re.match(reg2, text)
|
51 |
+
if match:
|
52 |
+
voice = match[1]
|
53 |
+
else:
|
54 |
+
print("No voice tag found, using main.")
|
55 |
+
voice = "main"
|
56 |
+
if voice not in voices:
|
57 |
+
print(f"Voice {voice} not found, using main.")
|
58 |
+
voice = "main"
|
59 |
+
text = re.sub(reg2, "", text)
|
60 |
+
gen_text = text.strip()
|
61 |
+
ref_audio = voices[voice]["ref_audio"]
|
62 |
+
ref_text = voices[voice]["ref_text"]
|
63 |
+
print(f"Voice: {voice}")
|
64 |
+
audio, final_sample_rate, spectragram = infer_process(
|
65 |
+
ref_audio, ref_text, gen_text, model_obj, vocoder, mel_spec_type=mel_spec_type, speed=speed
|
66 |
+
)
|
67 |
+
generated_audio_segments.append(audio)
|
68 |
+
|
69 |
+
if generated_audio_segments:
|
70 |
+
final_wave = np.concatenate(generated_audio_segments)
|
71 |
+
filename = f"{language.upper()}_{category.upper()}_{idx}.wav"
|
72 |
+
outfile_dir = os.path.join(output_dir, language)
|
73 |
+
os.makedirs(outfile_dir, exist_ok=True)
|
74 |
+
wave_path = Path(outfile_dir) / filename
|
75 |
+
with open(wave_path, "wb") as f:
|
76 |
+
sf.write(f.name, final_wave, final_sample_rate)
|
77 |
+
if remove_silence:
|
78 |
+
remove_silence_for_generated_wav(f.name)
|
79 |
+
print(f"Generated audio saved to: {f.name}")
|
80 |
+
|
81 |
+
|
82 |
+
def main():
|
83 |
+
parser = argparse.ArgumentParser(
|
84 |
+
prog="python3 infer-cli.py",
|
85 |
+
description="Commandline interface for E2/F5 TTS with Advanced Batch Processing.",
|
86 |
+
epilog="Specify options above to override one or more settings from config.",
|
87 |
+
)
|
88 |
+
|
89 |
+
parser.add_argument(
|
90 |
+
"-m",
|
91 |
+
"--model",
|
92 |
+
help="F5-TTS | E2-TTS",
|
93 |
+
)
|
94 |
+
parser.add_argument(
|
95 |
+
"-p",
|
96 |
+
"--ckpt_file",
|
97 |
+
help="The Checkpoint .pt",
|
98 |
+
)
|
99 |
+
parser.add_argument(
|
100 |
+
"-v",
|
101 |
+
"--vocab_file",
|
102 |
+
help="The vocab .txt",
|
103 |
+
)
|
104 |
+
|
105 |
+
parser.add_argument(
|
106 |
+
"-f",
|
107 |
+
"--generate_csv",
|
108 |
+
type=str,
|
109 |
+
)
|
110 |
+
parser.add_argument(
|
111 |
+
"-o",
|
112 |
+
"--output_dir",
|
113 |
+
type=str,
|
114 |
+
help="Path to output folder..",
|
115 |
+
)
|
116 |
+
parser.add_argument(
|
117 |
+
"--remove_silence",
|
118 |
+
help="Remove silence.",
|
119 |
+
)
|
120 |
+
parser.add_argument("--vocoder_name", type=str, default="vocos", choices=["vocos", "bigvgan"], help="vocoder name")
|
121 |
+
parser.add_argument(
|
122 |
+
"--load_vocoder_from_local",
|
123 |
+
action="store_true",
|
124 |
+
help="load vocoder from local. Default: ../checkpoints/charactr/vocos-mel-24khz",
|
125 |
+
)
|
126 |
+
parser.add_argument(
|
127 |
+
"--speed",
|
128 |
+
type=float,
|
129 |
+
default=1.0,
|
130 |
+
help="Adjust the speed of the audio generation (default: 1.0)",
|
131 |
+
)
|
132 |
+
args = parser.parse_args()
|
133 |
+
|
134 |
+
# Read texts and prompts to generate
|
135 |
+
filepath = args.generate_csv
|
136 |
+
df = pd.read_csv(filepath)
|
137 |
+
prompt_paths = df['prompt_path'].tolist()
|
138 |
+
prompt_texts = df['prompt_text'].tolist()
|
139 |
+
texts = df['text'].tolist()
|
140 |
+
languages = df['language'].tolist()
|
141 |
+
categories = df['category'].tolist()
|
142 |
+
|
143 |
+
# Model config
|
144 |
+
model = args.model
|
145 |
+
ckpt_file = args.ckpt_file
|
146 |
+
vocab_file = args.vocab_file
|
147 |
+
remove_silence = args.remove_silence
|
148 |
+
speed = args.speed
|
149 |
+
vocoder_name = args.vocoder_name
|
150 |
+
mel_spec_type = args.vocoder_name
|
151 |
+
if vocoder_name == "vocos":
|
152 |
+
vocoder_local_path = "../checkpoints/vocos-mel-24khz"
|
153 |
+
elif vocoder_name == "bigvgan":
|
154 |
+
vocoder_local_path = "../checkpoints/bigvgan_v2_24khz_100band_256x"
|
155 |
+
vocoder = load_vocoder(vocoder_name=mel_spec_type, is_local=args.load_vocoder_from_local, local_path=vocoder_local_path)
|
156 |
+
|
157 |
+
# load models
|
158 |
+
model_cls = DiT
|
159 |
+
model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
160 |
+
print(f"Using {model}...")
|
161 |
+
ema_model = load_model(model_cls, model_cfg, ckpt_file, mel_spec_type=mel_spec_type, vocab_file=vocab_file)
|
162 |
+
|
163 |
+
# Batch inference
|
164 |
+
output_dir = args.output_dir
|
165 |
+
if not os.path.exists(output_dir):
|
166 |
+
os.makedirs(output_dir)
|
167 |
+
run_batch_inference(prompt_paths, prompt_texts, texts, languages, categories, ema_model, vocoder, mel_spec_type, remove_silence, speed, output_dir)
|
168 |
+
|
169 |
+
|
170 |
+
if __name__ == "__main__":
|
171 |
+
main()
|
f5_tts/infer/infer_cli.py
ADDED
@@ -0,0 +1,226 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import codecs
|
3 |
+
import os
|
4 |
+
import re
|
5 |
+
from importlib.resources import files
|
6 |
+
from pathlib import Path
|
7 |
+
|
8 |
+
import numpy as np
|
9 |
+
import soundfile as sf
|
10 |
+
import tomli
|
11 |
+
from cached_path import cached_path
|
12 |
+
|
13 |
+
from f5_tts.infer.utils_infer import (
|
14 |
+
infer_process,
|
15 |
+
load_model,
|
16 |
+
load_vocoder,
|
17 |
+
preprocess_ref_audio_text,
|
18 |
+
remove_silence_for_generated_wav,
|
19 |
+
)
|
20 |
+
from f5_tts.model import DiT, UNetT
|
21 |
+
|
22 |
+
parser = argparse.ArgumentParser(
|
23 |
+
prog="python3 infer-cli.py",
|
24 |
+
description="Commandline interface for E2/F5 TTS with Advanced Batch Processing.",
|
25 |
+
epilog="Specify options above to override one or more settings from config.",
|
26 |
+
)
|
27 |
+
parser.add_argument(
|
28 |
+
"-c",
|
29 |
+
"--config",
|
30 |
+
help="Configuration file. Default=infer/examples/basic/basic.toml",
|
31 |
+
default=os.path.join(files("f5_tts").joinpath("infer/examples/basic"), "basic.toml"),
|
32 |
+
)
|
33 |
+
parser.add_argument(
|
34 |
+
"-m",
|
35 |
+
"--model",
|
36 |
+
help="F5-TTS | E2-TTS",
|
37 |
+
)
|
38 |
+
parser.add_argument(
|
39 |
+
"-p",
|
40 |
+
"--ckpt_file",
|
41 |
+
help="The Checkpoint .pt",
|
42 |
+
)
|
43 |
+
parser.add_argument(
|
44 |
+
"-v",
|
45 |
+
"--vocab_file",
|
46 |
+
help="The vocab .txt",
|
47 |
+
)
|
48 |
+
parser.add_argument("-r", "--ref_audio", type=str, help="Reference audio file < 15 seconds.")
|
49 |
+
parser.add_argument("-s", "--ref_text", type=str, default="666", help="Subtitle for the reference audio.")
|
50 |
+
parser.add_argument(
|
51 |
+
"-t",
|
52 |
+
"--gen_text",
|
53 |
+
type=str,
|
54 |
+
help="Text to generate.",
|
55 |
+
)
|
56 |
+
parser.add_argument(
|
57 |
+
"-f",
|
58 |
+
"--gen_file",
|
59 |
+
type=str,
|
60 |
+
help="File with text to generate. Ignores --gen_text",
|
61 |
+
)
|
62 |
+
parser.add_argument(
|
63 |
+
"-o",
|
64 |
+
"--output_dir",
|
65 |
+
type=str,
|
66 |
+
help="Path to output folder..",
|
67 |
+
)
|
68 |
+
parser.add_argument(
|
69 |
+
"-w",
|
70 |
+
"--output_file",
|
71 |
+
type=str,
|
72 |
+
help="Filename of output file..",
|
73 |
+
)
|
74 |
+
parser.add_argument(
|
75 |
+
"--remove_silence",
|
76 |
+
help="Remove silence.",
|
77 |
+
)
|
78 |
+
parser.add_argument("--vocoder_name", type=str, default="vocos", choices=["vocos", "bigvgan"], help="vocoder name")
|
79 |
+
parser.add_argument(
|
80 |
+
"--load_vocoder_from_local",
|
81 |
+
action="store_true",
|
82 |
+
help="load vocoder from local. Default: ../checkpoints/charactr/vocos-mel-24khz",
|
83 |
+
)
|
84 |
+
parser.add_argument(
|
85 |
+
"--speed",
|
86 |
+
type=float,
|
87 |
+
default=1.0,
|
88 |
+
help="Adjust the speed of the audio generation (default: 1.0)",
|
89 |
+
)
|
90 |
+
args = parser.parse_args()
|
91 |
+
|
92 |
+
config = tomli.load(open(args.config, "rb"))
|
93 |
+
|
94 |
+
ref_audio = args.ref_audio if args.ref_audio else config["ref_audio"]
|
95 |
+
ref_text = args.ref_text if args.ref_text != "666" else config["ref_text"]
|
96 |
+
gen_text = args.gen_text if args.gen_text else config["gen_text"]
|
97 |
+
gen_file = args.gen_file if args.gen_file else config["gen_file"]
|
98 |
+
|
99 |
+
# patches for pip pkg user
|
100 |
+
if "infer/examples/" in ref_audio:
|
101 |
+
ref_audio = str(files("f5_tts").joinpath(f"{ref_audio}"))
|
102 |
+
if "infer/examples/" in gen_file:
|
103 |
+
gen_file = str(files("f5_tts").joinpath(f"{gen_file}"))
|
104 |
+
if "voices" in config:
|
105 |
+
for voice in config["voices"]:
|
106 |
+
voice_ref_audio = config["voices"][voice]["ref_audio"]
|
107 |
+
if "infer/examples/" in voice_ref_audio:
|
108 |
+
config["voices"][voice]["ref_audio"] = str(files("f5_tts").joinpath(f"{voice_ref_audio}"))
|
109 |
+
|
110 |
+
if gen_file:
|
111 |
+
gen_text = codecs.open(gen_file, "r", "utf-8").read()
|
112 |
+
output_dir = args.output_dir if args.output_dir else config["output_dir"]
|
113 |
+
output_file = args.output_file if args.output_file else config["output_file"]
|
114 |
+
model = args.model if args.model else config["model"]
|
115 |
+
ckpt_file = args.ckpt_file if args.ckpt_file else ""
|
116 |
+
vocab_file = args.vocab_file if args.vocab_file else ""
|
117 |
+
remove_silence = args.remove_silence if args.remove_silence else config["remove_silence"]
|
118 |
+
speed = args.speed
|
119 |
+
|
120 |
+
wave_path = Path(output_dir) / output_file
|
121 |
+
# spectrogram_path = Path(output_dir) / "infer_cli_out.png"
|
122 |
+
|
123 |
+
vocoder_name = args.vocoder_name
|
124 |
+
mel_spec_type = args.vocoder_name
|
125 |
+
if vocoder_name == "vocos":
|
126 |
+
vocoder_local_path = "../checkpoints/vocos-mel-24khz"
|
127 |
+
elif vocoder_name == "bigvgan":
|
128 |
+
vocoder_local_path = "../checkpoints/bigvgan_v2_24khz_100band_256x"
|
129 |
+
|
130 |
+
vocoder = load_vocoder(vocoder_name=mel_spec_type, is_local=args.load_vocoder_from_local, local_path=vocoder_local_path)
|
131 |
+
|
132 |
+
|
133 |
+
# load models
|
134 |
+
if model == "F5-TTS":
|
135 |
+
model_cls = DiT
|
136 |
+
model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
137 |
+
if ckpt_file == "":
|
138 |
+
if vocoder_name == "vocos":
|
139 |
+
repo_name = "F5-TTS"
|
140 |
+
exp_name = "F5TTS_Base"
|
141 |
+
ckpt_step = 1200000
|
142 |
+
ckpt_file = "/home/tts/ttsteam/repos/en_f5/F5-TTS/ckpts/expresso/model_356000.pt"
|
143 |
+
# ckpt_file = f"ckpts/{exp_name}/model_{ckpt_step}.pt" # .pt | .safetensors; local path
|
144 |
+
elif vocoder_name == "bigvgan":
|
145 |
+
repo_name = "F5-TTS"
|
146 |
+
exp_name = "F5TTS_Base_bigvgan"
|
147 |
+
ckpt_step = 1250000
|
148 |
+
ckpt_file = str(cached_path(f"hf://SWivid/{repo_name}/{exp_name}/model_{ckpt_step}.pt"))
|
149 |
+
|
150 |
+
elif model == "E2-TTS":
|
151 |
+
assert vocoder_name == "vocos", "E2-TTS only supports vocoder vocos"
|
152 |
+
model_cls = UNetT
|
153 |
+
model_cfg = dict(dim=1024, depth=24, heads=16, ff_mult=4)
|
154 |
+
if ckpt_file == "":
|
155 |
+
repo_name = "E2-TTS"
|
156 |
+
exp_name = "E2TTS_Base"
|
157 |
+
ckpt_step = 1200000
|
158 |
+
ckpt_file = str(cached_path(f"hf://SWivid/{repo_name}/{exp_name}/model_{ckpt_step}.safetensors"))
|
159 |
+
# ckpt_file = f"ckpts/{exp_name}/model_{ckpt_step}.pt" # .pt | .safetensors; local path
|
160 |
+
|
161 |
+
|
162 |
+
print(f"Using {model}...")
|
163 |
+
ema_model = load_model(model_cls, model_cfg, ckpt_file, mel_spec_type=mel_spec_type, vocab_file=vocab_file)
|
164 |
+
|
165 |
+
|
166 |
+
def main_process(ref_audio, ref_text, text_gen, model_obj, mel_spec_type, remove_silence, speed):
|
167 |
+
main_voice = {"ref_audio": ref_audio, "ref_text": ref_text}
|
168 |
+
if "voices" not in config:
|
169 |
+
voices = {"main": main_voice}
|
170 |
+
else:
|
171 |
+
voices = config["voices"]
|
172 |
+
voices["main"] = main_voice
|
173 |
+
for voice in voices:
|
174 |
+
voices[voice]["ref_audio"], voices[voice]["ref_text"] = preprocess_ref_audio_text(
|
175 |
+
voices[voice]["ref_audio"], voices[voice]["ref_text"]
|
176 |
+
)
|
177 |
+
print("Voice:", voice)
|
178 |
+
print("Ref_audio:", voices[voice]["ref_audio"])
|
179 |
+
print("Ref_text:", voices[voice]["ref_text"])
|
180 |
+
|
181 |
+
generated_audio_segments = []
|
182 |
+
reg1 = r"(?=\[\w+\])"
|
183 |
+
chunks = re.split(reg1, text_gen)
|
184 |
+
reg2 = r"\[(\w+)\]"
|
185 |
+
for text in chunks:
|
186 |
+
if not text.strip():
|
187 |
+
continue
|
188 |
+
match = re.match(reg2, text)
|
189 |
+
if match:
|
190 |
+
voice = match[1]
|
191 |
+
else:
|
192 |
+
print("No voice tag found, using main.")
|
193 |
+
voice = "main"
|
194 |
+
if voice not in voices:
|
195 |
+
print(f"Voice {voice} not found, using main.")
|
196 |
+
voice = "main"
|
197 |
+
text = re.sub(reg2, "", text)
|
198 |
+
gen_text = text.strip()
|
199 |
+
ref_audio = voices[voice]["ref_audio"]
|
200 |
+
ref_text = voices[voice]["ref_text"]
|
201 |
+
print(f"Voice: {voice}")
|
202 |
+
audio, final_sample_rate, spectragram = infer_process(
|
203 |
+
ref_audio, ref_text, gen_text, model_obj, vocoder, mel_spec_type=mel_spec_type, speed=speed
|
204 |
+
)
|
205 |
+
generated_audio_segments.append(audio)
|
206 |
+
|
207 |
+
if generated_audio_segments:
|
208 |
+
final_wave = np.concatenate(generated_audio_segments)
|
209 |
+
|
210 |
+
if not os.path.exists(output_dir):
|
211 |
+
os.makedirs(output_dir)
|
212 |
+
|
213 |
+
with open(wave_path, "wb") as f:
|
214 |
+
sf.write(f.name, final_wave, final_sample_rate)
|
215 |
+
# Remove silence
|
216 |
+
if remove_silence:
|
217 |
+
remove_silence_for_generated_wav(f.name)
|
218 |
+
print(f.name)
|
219 |
+
|
220 |
+
|
221 |
+
def main():
|
222 |
+
main_process(ref_audio, ref_text, gen_text, ema_model, mel_spec_type, remove_silence, speed)
|
223 |
+
|
224 |
+
|
225 |
+
if __name__ == "__main__":
|
226 |
+
main()
|
f5_tts/infer/infer_cli_batch.py
ADDED
@@ -0,0 +1,245 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import codecs
|
3 |
+
import os
|
4 |
+
import re
|
5 |
+
from importlib.resources import files
|
6 |
+
from pathlib import Path
|
7 |
+
|
8 |
+
import numpy as np
|
9 |
+
import soundfile as sf
|
10 |
+
import tomli
|
11 |
+
from cached_path import cached_path
|
12 |
+
import pandas as pd
|
13 |
+
|
14 |
+
from f5_tts.infer.utils_infer import (
|
15 |
+
infer_process,
|
16 |
+
load_model,
|
17 |
+
load_vocoder,
|
18 |
+
preprocess_ref_audio_text,
|
19 |
+
remove_silence_for_generated_wav,
|
20 |
+
)
|
21 |
+
from f5_tts.model import DiT, UNetT
|
22 |
+
|
23 |
+
parser = argparse.ArgumentParser(
|
24 |
+
prog="python3 infer-cli.py",
|
25 |
+
description="Commandline interface for E2/F5 TTS with Advanced Batch Processing.",
|
26 |
+
epilog="Specify options above to override one or more settings from config.",
|
27 |
+
)
|
28 |
+
parser.add_argument(
|
29 |
+
"-c",
|
30 |
+
"--config",
|
31 |
+
help="Configuration file. Default=infer/examples/basic/basic.toml",
|
32 |
+
default=os.path.join(files("f5_tts").joinpath("infer/examples/basic"), "basic.toml"),
|
33 |
+
)
|
34 |
+
parser.add_argument(
|
35 |
+
"-m",
|
36 |
+
"--model",
|
37 |
+
help="F5-TTS | E2-TTS",
|
38 |
+
)
|
39 |
+
parser.add_argument(
|
40 |
+
"-p",
|
41 |
+
"--ckpt_file",
|
42 |
+
help="The Checkpoint .pt",
|
43 |
+
)
|
44 |
+
parser.add_argument(
|
45 |
+
"-v",
|
46 |
+
"--vocab_file",
|
47 |
+
help="The vocab .txt",
|
48 |
+
)
|
49 |
+
parser.add_argument("-r", "--ref_audio", type=str, help="Reference audio file < 15 seconds.")
|
50 |
+
parser.add_argument("-s", "--ref_text", type=str, default="666", help="Subtitle for the reference audio.")
|
51 |
+
parser.add_argument(
|
52 |
+
"-t",
|
53 |
+
"--gen_text",
|
54 |
+
type=str,
|
55 |
+
help="Text to generate.",
|
56 |
+
)
|
57 |
+
parser.add_argument(
|
58 |
+
"-f",
|
59 |
+
"--gen_file",
|
60 |
+
type=str,
|
61 |
+
help="File with text to generate. Ignores --gen_text",
|
62 |
+
)
|
63 |
+
parser.add_argument(
|
64 |
+
"-o",
|
65 |
+
"--output_dir",
|
66 |
+
type=str,
|
67 |
+
help="Path to output folder..",
|
68 |
+
)
|
69 |
+
parser.add_argument(
|
70 |
+
"-w",
|
71 |
+
"--output_file",
|
72 |
+
type=str,
|
73 |
+
help="Filename of output file..",
|
74 |
+
)
|
75 |
+
parser.add_argument(
|
76 |
+
"--remove_silence",
|
77 |
+
help="Remove silence.",
|
78 |
+
)
|
79 |
+
parser.add_argument("--vocoder_name", type=str, default="vocos", choices=["vocos", "bigvgan"], help="vocoder name")
|
80 |
+
parser.add_argument(
|
81 |
+
"--load_vocoder_from_local",
|
82 |
+
action="store_true",
|
83 |
+
help="load vocoder from local. Default: ../checkpoints/charactr/vocos-mel-24khz",
|
84 |
+
)
|
85 |
+
parser.add_argument(
|
86 |
+
"--speed",
|
87 |
+
type=float,
|
88 |
+
default=1.0,
|
89 |
+
help="Adjust the speed of the audio generation (default: 1.0)",
|
90 |
+
)
|
91 |
+
args = parser.parse_args()
|
92 |
+
|
93 |
+
config = tomli.load(open(args.config, "rb"))
|
94 |
+
|
95 |
+
ref_audio = args.ref_audio if args.ref_audio else config["ref_audio"]
|
96 |
+
ref_text = args.ref_text if args.ref_text != "666" else config["ref_text"]
|
97 |
+
gen_file = args.gen_file if args.gen_file else config["gen_file"]
|
98 |
+
|
99 |
+
|
100 |
+
if gen_file:
|
101 |
+
# Read texts from CSV file
|
102 |
+
df = pd.read_csv(gen_file)
|
103 |
+
text_list = df['text'].tolist()
|
104 |
+
else:
|
105 |
+
# If no file provided, use single text
|
106 |
+
gen_text = args.gen_text if args.gen_text else config["gen_text"]
|
107 |
+
text_list = [gen_text]
|
108 |
+
output_dir = args.output_dir if args.output_dir else config["output_dir"]
|
109 |
+
output_file = args.output_file if args.output_file else config["output_file"]
|
110 |
+
model = args.model if args.model else config["model"]
|
111 |
+
ckpt_file = args.ckpt_file if args.ckpt_file else ""
|
112 |
+
vocab_file = args.vocab_file if args.vocab_file else ""
|
113 |
+
remove_silence = args.remove_silence if args.remove_silence else config["remove_silence"]
|
114 |
+
speed = args.speed
|
115 |
+
|
116 |
+
wave_path = Path(output_dir) / output_file
|
117 |
+
# spectrogram_path = Path(output_dir) / "infer_cli_out.png"
|
118 |
+
|
119 |
+
|
120 |
+
# patches for pip pkg user
|
121 |
+
if "infer/examples/" in ref_audio:
|
122 |
+
ref_audio = str(files("f5_tts").joinpath(f"{ref_audio}"))
|
123 |
+
if "infer/examples/" in gen_file:
|
124 |
+
gen_file = str(files("f5_tts").joinpath(f"{gen_file}"))
|
125 |
+
if "voices" in config:
|
126 |
+
for voice in config["voices"]:
|
127 |
+
voice_ref_audio = config["voices"][voice]["ref_audio"]
|
128 |
+
if "infer/examples/" in voice_ref_audio:
|
129 |
+
config["voices"][voice]["ref_audio"] = str(files("f5_tts").joinpath(f"{voice_ref_audio}"))
|
130 |
+
|
131 |
+
vocoder_name = args.vocoder_name
|
132 |
+
mel_spec_type = args.vocoder_name
|
133 |
+
if vocoder_name == "vocos":
|
134 |
+
vocoder_local_path = "../checkpoints/vocos-mel-24khz"
|
135 |
+
elif vocoder_name == "bigvgan":
|
136 |
+
vocoder_local_path = "../checkpoints/bigvgan_v2_24khz_100band_256x"
|
137 |
+
|
138 |
+
vocoder = load_vocoder(vocoder_name=mel_spec_type, is_local=args.load_vocoder_from_local, local_path=vocoder_local_path)
|
139 |
+
|
140 |
+
|
141 |
+
# load models
|
142 |
+
if model == "F5-TTS":
|
143 |
+
model_cls = DiT
|
144 |
+
model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
145 |
+
if ckpt_file == "":
|
146 |
+
if vocoder_name == "vocos":
|
147 |
+
repo_name = "F5-TTS"
|
148 |
+
exp_name = "F5TTS_Base"
|
149 |
+
ckpt_step = 1200000
|
150 |
+
ckpt_file = str(cached_path(f"hf://SWivid/{repo_name}/{exp_name}/model_{ckpt_step}.safetensors"))
|
151 |
+
# ckpt_file = f"ckpts/{exp_name}/model_{ckpt_step}.pt" # .pt | .safetensors; local path
|
152 |
+
elif vocoder_name == "bigvgan":
|
153 |
+
repo_name = "F5-TTS"
|
154 |
+
exp_name = "F5TTS_Base_bigvgan"
|
155 |
+
ckpt_step = 1250000
|
156 |
+
ckpt_file = str(cached_path(f"hf://SWivid/{repo_name}/{exp_name}/model_{ckpt_step}.pt"))
|
157 |
+
|
158 |
+
elif model == "E2-TTS":
|
159 |
+
assert vocoder_name == "vocos", "E2-TTS only supports vocoder vocos"
|
160 |
+
model_cls = UNetT
|
161 |
+
model_cfg = dict(dim=1024, depth=24, heads=16, ff_mult=4)
|
162 |
+
if ckpt_file == "":
|
163 |
+
repo_name = "E2-TTS"
|
164 |
+
exp_name = "E2TTS_Base"
|
165 |
+
ckpt_step = 1200000
|
166 |
+
ckpt_file = str(cached_path(f"hf://SWivid/{repo_name}/{exp_name}/model_{ckpt_step}.safetensors"))
|
167 |
+
# ckpt_file = f"ckpts/{exp_name}/model_{ckpt_step}.pt" # .pt | .safetensors; local path
|
168 |
+
|
169 |
+
|
170 |
+
print(f"Using {model}...")
|
171 |
+
ema_model = load_model(model_cls, model_cfg, ckpt_file, mel_spec_type=mel_spec_type, vocab_file=vocab_file)
|
172 |
+
|
173 |
+
|
174 |
+
def main_process(ref_audio, ref_text, text_list, model_obj, mel_spec_type, remove_silence, speed):
|
175 |
+
main_voice = {"ref_audio": ref_audio, "ref_text": ref_text}
|
176 |
+
if "voices" not in config:
|
177 |
+
voices = {"main": main_voice}
|
178 |
+
else:
|
179 |
+
voices = config["voices"]
|
180 |
+
voices["main"] = main_voice
|
181 |
+
for voice in voices:
|
182 |
+
voices[voice]["ref_audio"], voices[voice]["ref_text"] = preprocess_ref_audio_text(
|
183 |
+
voices[voice]["ref_audio"], voices[voice]["ref_text"]
|
184 |
+
)
|
185 |
+
print("Voice:", voice)
|
186 |
+
print("Ref_audio:", voices[voice]["ref_audio"])
|
187 |
+
print("Ref_text:", voices[voice]["ref_text"])
|
188 |
+
|
189 |
+
# Process each text in the list
|
190 |
+
for idx, text_gen in enumerate(text_list):
|
191 |
+
generated_audio_segments = []
|
192 |
+
reg1 = r"(?=\[\w+\])"
|
193 |
+
chunks = re.split(reg1, text_gen)
|
194 |
+
reg2 = r"\[(\w+)\]"
|
195 |
+
for text in chunks:
|
196 |
+
if not text.strip():
|
197 |
+
continue
|
198 |
+
match = re.match(reg2, text)
|
199 |
+
if match:
|
200 |
+
voice = match[1]
|
201 |
+
else:
|
202 |
+
print("No voice tag found, using main.")
|
203 |
+
voice = "main"
|
204 |
+
if voice not in voices:
|
205 |
+
print(f"Voice {voice} not found, using main.")
|
206 |
+
voice = "main"
|
207 |
+
text = re.sub(reg2, "", text)
|
208 |
+
gen_text = text.strip()
|
209 |
+
ref_audio = voices[voice]["ref_audio"]
|
210 |
+
ref_text = voices[voice]["ref_text"]
|
211 |
+
print(f"Voice: {voice}")
|
212 |
+
audio, final_sample_rate, spectragram = infer_process(
|
213 |
+
ref_audio, ref_text, gen_text, model_obj, vocoder, mel_spec_type=mel_spec_type, speed=speed
|
214 |
+
)
|
215 |
+
generated_audio_segments.append(audio)
|
216 |
+
|
217 |
+
if generated_audio_segments:
|
218 |
+
final_wave = np.concatenate(generated_audio_segments)
|
219 |
+
|
220 |
+
if not os.path.exists(output_dir):
|
221 |
+
os.makedirs(output_dir)
|
222 |
+
|
223 |
+
# Get first 3 words from the text
|
224 |
+
first_three_words = '_'.join(text_gen.split()[:3])
|
225 |
+
# Remove any special characters that might cause issues in filenames
|
226 |
+
first_three_words = re.sub(r'[^\w\s-]', '', first_three_words)
|
227 |
+
# Create filename with index and first 3 words
|
228 |
+
filename = f"{Path(output_file).stem}__sentence{(idx+1):03d}_{first_three_words}{Path(output_file).suffix}"
|
229 |
+
|
230 |
+
wave_path = Path(output_dir) / filename
|
231 |
+
|
232 |
+
with open(wave_path, "wb") as f:
|
233 |
+
sf.write(f.name, final_wave, final_sample_rate)
|
234 |
+
# Remove silence
|
235 |
+
if remove_silence:
|
236 |
+
remove_silence_for_generated_wav(f.name)
|
237 |
+
print(f"Generated audio saved to: {f.name}")
|
238 |
+
|
239 |
+
|
240 |
+
def main():
|
241 |
+
main_process(ref_audio, ref_text, text_list, ema_model, mel_spec_type, remove_silence, speed)
|
242 |
+
|
243 |
+
|
244 |
+
if __name__ == "__main__":
|
245 |
+
main()
|
f5_tts/infer/infer_gradio.py
ADDED
@@ -0,0 +1,855 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
7 |
+
import tempfile
|
8 |
+
from datetime import datetime
|
9 |
+
from collections import OrderedDict
|
10 |
+
from importlib.resources import files
|
11 |
+
|
12 |
+
import click
|
13 |
+
import gradio as gr
|
14 |
+
import numpy as np
|
15 |
+
import soundfile as sf
|
16 |
+
import torchaudio
|
17 |
+
from cached_path import cached_path
|
18 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
19 |
+
|
20 |
+
try:
|
21 |
+
import spaces
|
22 |
+
|
23 |
+
USING_SPACES = True
|
24 |
+
except ImportError:
|
25 |
+
USING_SPACES = False
|
26 |
+
|
27 |
+
|
28 |
+
def gpu_decorator(func):
|
29 |
+
if USING_SPACES:
|
30 |
+
return spaces.GPU(func)
|
31 |
+
else:
|
32 |
+
return func
|
33 |
+
|
34 |
+
|
35 |
+
from f5_tts.model import DiT, UNetT
|
36 |
+
from f5_tts.infer.utils_infer import (
|
37 |
+
load_vocoder,
|
38 |
+
load_model,
|
39 |
+
preprocess_ref_audio_text,
|
40 |
+
infer_process,
|
41 |
+
remove_silence_for_generated_wav,
|
42 |
+
save_spectrogram,
|
43 |
+
)
|
44 |
+
|
45 |
+
|
46 |
+
DEFAULT_TTS_MODEL = "F5-TTS"
|
47 |
+
tts_model_choice = DEFAULT_TTS_MODEL
|
48 |
+
|
49 |
+
|
50 |
+
# load models
|
51 |
+
|
52 |
+
vocoder = load_vocoder()
|
53 |
+
|
54 |
+
|
55 |
+
def load_f5tts(ckpt_path=str(cached_path("hf://SWivid/F5-TTS/F5TTS_Base/model_1200000.safetensors"))):
|
56 |
+
F5TTS_model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
57 |
+
|
58 |
+
ckpt_path = "/home/tts/ttsteam/repos/F5-TTS/runs/indic_5/model_1176000.pt"
|
59 |
+
vocab_path = "/home/tts/ttsteam/repos/F5-TTS/runs/indic_5/vocab.txt"
|
60 |
+
return load_model(DiT, F5TTS_model_cfg, ckpt_path, vocab_file=vocab_path)
|
61 |
+
|
62 |
+
|
63 |
+
def load_e2tts(ckpt_path=str(cached_path("hf://SWivid/E2-TTS/E2TTS_Base/model_1200000.safetensors"))):
|
64 |
+
E2TTS_model_cfg = dict(dim=1024, depth=24, heads=16, ff_mult=4)
|
65 |
+
return load_model(UNetT, E2TTS_model_cfg, ckpt_path)
|
66 |
+
|
67 |
+
|
68 |
+
def load_custom(ckpt_path: str, vocab_path="", model_cfg=None):
|
69 |
+
ckpt_path, vocab_path = ckpt_path.strip(), vocab_path.strip()
|
70 |
+
if ckpt_path.startswith("hf://"):
|
71 |
+
ckpt_path = str(cached_path(ckpt_path))
|
72 |
+
if vocab_path.startswith("hf://"):
|
73 |
+
vocab_path = str(cached_path(vocab_path))
|
74 |
+
if model_cfg is None:
|
75 |
+
model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
76 |
+
return load_model(DiT, model_cfg, ckpt_path, vocab_file=vocab_path)
|
77 |
+
|
78 |
+
|
79 |
+
F5TTS_ema_model = load_f5tts()
|
80 |
+
E2TTS_ema_model = load_e2tts() if USING_SPACES else None
|
81 |
+
custom_ema_model, pre_custom_path = None, ""
|
82 |
+
|
83 |
+
chat_model_state = None
|
84 |
+
chat_tokenizer_state = None
|
85 |
+
|
86 |
+
|
87 |
+
@gpu_decorator
|
88 |
+
def generate_response(messages, model, tokenizer):
|
89 |
+
"""Generate response using Qwen"""
|
90 |
+
text = tokenizer.apply_chat_template(
|
91 |
+
messages,
|
92 |
+
tokenize=False,
|
93 |
+
add_generation_prompt=True,
|
94 |
+
)
|
95 |
+
|
96 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
97 |
+
generated_ids = model.generate(
|
98 |
+
**model_inputs,
|
99 |
+
max_new_tokens=512,
|
100 |
+
temperature=0.7,
|
101 |
+
top_p=0.95,
|
102 |
+
)
|
103 |
+
|
104 |
+
generated_ids = [
|
105 |
+
output_ids[len(input_ids) :] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
106 |
+
]
|
107 |
+
return tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
108 |
+
|
109 |
+
|
110 |
+
@gpu_decorator
|
111 |
+
def infer(
|
112 |
+
ref_audio_orig, ref_text, gen_text, model, remove_silence, cross_fade_duration=0.15, speed=1, show_info=gr.Info
|
113 |
+
):
|
114 |
+
|
115 |
+
print("ref audio is: ", type(ref_audio_orig), ref_audio_orig)
|
116 |
+
current_time = datetime.now().strftime("%Y%m%d_%H%M%S")
|
117 |
+
shutil.copy(ref_audio_orig, os.path.join("/home/tts/ttsteam/repos/F5-TTS/runs/indic_5/infers", f"reference_audio_{current_time}.wav"))
|
118 |
+
ref_audio, ref_text = preprocess_ref_audio_text(ref_audio_orig, ref_text, show_info=show_info)
|
119 |
+
|
120 |
+
if model == "F5-TTS":
|
121 |
+
ema_model = F5TTS_ema_model
|
122 |
+
elif model == "E2-TTS":
|
123 |
+
global E2TTS_ema_model
|
124 |
+
if E2TTS_ema_model is None:
|
125 |
+
show_info("Loading E2-TTS model...")
|
126 |
+
E2TTS_ema_model = load_e2tts()
|
127 |
+
ema_model = E2TTS_ema_model
|
128 |
+
elif isinstance(model, list) and model[0] == "Custom":
|
129 |
+
assert not USING_SPACES, "Only official checkpoints allowed in Spaces."
|
130 |
+
global custom_ema_model, pre_custom_path
|
131 |
+
if pre_custom_path != model[1]:
|
132 |
+
show_info("Loading Custom TTS model...")
|
133 |
+
custom_ema_model = load_custom(model[1], vocab_path=model[2])
|
134 |
+
pre_custom_path = model[1]
|
135 |
+
ema_model = custom_ema_model
|
136 |
+
|
137 |
+
final_wave, final_sample_rate, combined_spectrogram = infer_process(
|
138 |
+
ref_audio,
|
139 |
+
ref_text,
|
140 |
+
gen_text,
|
141 |
+
ema_model,
|
142 |
+
vocoder,
|
143 |
+
cross_fade_duration=cross_fade_duration,
|
144 |
+
speed=speed,
|
145 |
+
show_info=show_info,
|
146 |
+
progress=gr.Progress(),
|
147 |
+
)
|
148 |
+
|
149 |
+
# Remove silence
|
150 |
+
if remove_silence:
|
151 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
|
152 |
+
sf.write(f.name, final_wave, final_sample_rate)
|
153 |
+
remove_silence_for_generated_wav(f.name)
|
154 |
+
final_wave, _ = torchaudio.load(f.name)
|
155 |
+
final_wave = final_wave.squeeze().cpu().numpy()
|
156 |
+
|
157 |
+
gen_time = datetime.now().strftime("%Y%m%d_%H%M%S")
|
158 |
+
sf.write(os.path.join("/home/tts/ttsteam/repos/F5-TTS/runs/indic_5/infers", f"reference_audio_{current_time}_gen_{gen_time}.wav"), final_wave, final_sample_rate)
|
159 |
+
|
160 |
+
# Save the spectrogram
|
161 |
+
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp_spectrogram:
|
162 |
+
spectrogram_path = tmp_spectrogram.name
|
163 |
+
save_spectrogram(combined_spectrogram, spectrogram_path)
|
164 |
+
|
165 |
+
return (final_sample_rate, final_wave), spectrogram_path, ref_text
|
166 |
+
|
167 |
+
|
168 |
+
with gr.Blocks() as app_credits:
|
169 |
+
gr.Markdown("""
|
170 |
+
# Credits
|
171 |
+
|
172 |
+
* [mrfakename](https://github.com/fakerybakery) for the original [online demo](https://huggingface.co/spaces/mrfakename/E2-F5-TTS)
|
173 |
+
* [RootingInLoad](https://github.com/RootingInLoad) for initial chunk generation and podcast app exploration
|
174 |
+
* [jpgallegoar](https://github.com/jpgallegoar) for multiple speech-type generation & voice chat
|
175 |
+
""")
|
176 |
+
with gr.Blocks() as app_tts:
|
177 |
+
gr.Markdown("# Batched TTS")
|
178 |
+
ref_audio_input = gr.Audio(label="Reference Audio", type="filepath")
|
179 |
+
gen_text_input = gr.Textbox(label="Text to Generate", lines=10)
|
180 |
+
generate_btn = gr.Button("Synthesize", variant="primary")
|
181 |
+
with gr.Accordion("Advanced Settings", open=False):
|
182 |
+
ref_text_input = gr.Textbox(
|
183 |
+
label="Reference Text",
|
184 |
+
info="Leave blank to automatically transcribe the reference audio. If you enter text it will override automatic transcription.",
|
185 |
+
lines=2,
|
186 |
+
)
|
187 |
+
remove_silence = gr.Checkbox(
|
188 |
+
label="Remove Silences",
|
189 |
+
info="The model tends to produce silences, especially on longer audio. We can manually remove silences if needed. Note that this is an experimental feature and may produce strange results. This will also increase generation time.",
|
190 |
+
value=False,
|
191 |
+
)
|
192 |
+
speed_slider = gr.Slider(
|
193 |
+
label="Speed",
|
194 |
+
minimum=0.3,
|
195 |
+
maximum=3.0,
|
196 |
+
value=1.0,
|
197 |
+
step=0.1,
|
198 |
+
info="Adjust the speed of the audio.",
|
199 |
+
)
|
200 |
+
cross_fade_duration_slider = gr.Slider(
|
201 |
+
label="Cross-Fade Duration (s)",
|
202 |
+
minimum=0.0,
|
203 |
+
maximum=1.0,
|
204 |
+
value=0.15,
|
205 |
+
step=0.01,
|
206 |
+
info="Set the duration of the cross-fade between audio clips.",
|
207 |
+
)
|
208 |
+
|
209 |
+
audio_output = gr.Audio(label="Synthesized Audio")
|
210 |
+
spectrogram_output = gr.Image(label="Spectrogram")
|
211 |
+
|
212 |
+
@gpu_decorator
|
213 |
+
def basic_tts(
|
214 |
+
ref_audio_input,
|
215 |
+
ref_text_input,
|
216 |
+
gen_text_input,
|
217 |
+
remove_silence,
|
218 |
+
cross_fade_duration_slider,
|
219 |
+
speed_slider,
|
220 |
+
):
|
221 |
+
audio_out, spectrogram_path, ref_text_out = infer(
|
222 |
+
ref_audio_input,
|
223 |
+
ref_text_input,
|
224 |
+
gen_text_input,
|
225 |
+
tts_model_choice,
|
226 |
+
remove_silence,
|
227 |
+
cross_fade_duration_slider,
|
228 |
+
speed_slider,
|
229 |
+
)
|
230 |
+
return audio_out, spectrogram_path, gr.update(value=ref_text_out)
|
231 |
+
|
232 |
+
generate_btn.click(
|
233 |
+
basic_tts,
|
234 |
+
inputs=[
|
235 |
+
ref_audio_input,
|
236 |
+
ref_text_input,
|
237 |
+
gen_text_input,
|
238 |
+
remove_silence,
|
239 |
+
cross_fade_duration_slider,
|
240 |
+
speed_slider,
|
241 |
+
],
|
242 |
+
outputs=[audio_output, spectrogram_output, ref_text_input],
|
243 |
+
)
|
244 |
+
|
245 |
+
|
246 |
+
def parse_speechtypes_text(gen_text):
|
247 |
+
# Pattern to find {speechtype}
|
248 |
+
pattern = r"\{(.*?)\}"
|
249 |
+
|
250 |
+
# Split the text by the pattern
|
251 |
+
tokens = re.split(pattern, gen_text)
|
252 |
+
|
253 |
+
segments = []
|
254 |
+
|
255 |
+
current_style = "Regular"
|
256 |
+
|
257 |
+
for i in range(len(tokens)):
|
258 |
+
if i % 2 == 0:
|
259 |
+
# This is text
|
260 |
+
text = tokens[i].strip()
|
261 |
+
if text:
|
262 |
+
segments.append({"style": current_style, "text": text})
|
263 |
+
else:
|
264 |
+
# This is style
|
265 |
+
style = tokens[i].strip()
|
266 |
+
current_style = style
|
267 |
+
|
268 |
+
return segments
|
269 |
+
|
270 |
+
|
271 |
+
with gr.Blocks() as app_multistyle:
|
272 |
+
# New section for multistyle generation
|
273 |
+
gr.Markdown(
|
274 |
+
"""
|
275 |
+
# Multiple Speech-Type Generation
|
276 |
+
|
277 |
+
This section allows you to generate multiple speech types or multiple people's voices. Enter your text in the format shown below, and the system will generate speech using the appropriate type. If unspecified, the model will use the regular speech type. The current speech type will be used until the next speech type is specified.
|
278 |
+
"""
|
279 |
+
)
|
280 |
+
|
281 |
+
with gr.Row():
|
282 |
+
gr.Markdown(
|
283 |
+
"""
|
284 |
+
**Example Input:**
|
285 |
+
{Regular} Hello, I'd like to order a sandwich please.
|
286 |
+
{Surprised} What do you mean you're out of bread?
|
287 |
+
{Sad} I really wanted a sandwich though...
|
288 |
+
{Angry} You know what, darn you and your little shop!
|
289 |
+
{Whisper} I'll just go back home and cry now.
|
290 |
+
{Shouting} Why me?!
|
291 |
+
"""
|
292 |
+
)
|
293 |
+
|
294 |
+
gr.Markdown(
|
295 |
+
"""
|
296 |
+
**Example Input 2:**
|
297 |
+
{Speaker1_Happy} Hello, I'd like to order a sandwich please.
|
298 |
+
{Speaker2_Regular} Sorry, we're out of bread.
|
299 |
+
{Speaker1_Sad} I really wanted a sandwich though...
|
300 |
+
{Speaker2_Whisper} I'll give you the last one I was hiding.
|
301 |
+
"""
|
302 |
+
)
|
303 |
+
|
304 |
+
gr.Markdown(
|
305 |
+
"Upload different audio clips for each speech type. The first speech type is mandatory. You can add additional speech types by clicking the 'Add Speech Type' button."
|
306 |
+
)
|
307 |
+
|
308 |
+
# Regular speech type (mandatory)
|
309 |
+
with gr.Row():
|
310 |
+
with gr.Column():
|
311 |
+
regular_name = gr.Textbox(value="Regular", label="Speech Type Name")
|
312 |
+
regular_insert = gr.Button("Insert Label", variant="secondary")
|
313 |
+
regular_audio = gr.Audio(label="Regular Reference Audio", type="filepath")
|
314 |
+
regular_ref_text = gr.Textbox(label="Reference Text (Regular)", lines=2)
|
315 |
+
|
316 |
+
# Regular speech type (max 100)
|
317 |
+
max_speech_types = 100
|
318 |
+
speech_type_rows = [] # 99
|
319 |
+
speech_type_names = [regular_name] # 100
|
320 |
+
speech_type_audios = [regular_audio] # 100
|
321 |
+
speech_type_ref_texts = [regular_ref_text] # 100
|
322 |
+
speech_type_delete_btns = [] # 99
|
323 |
+
speech_type_insert_btns = [regular_insert] # 100
|
324 |
+
|
325 |
+
# Additional speech types (99 more)
|
326 |
+
for i in range(max_speech_types - 1):
|
327 |
+
with gr.Row(visible=False) as row:
|
328 |
+
with gr.Column():
|
329 |
+
name_input = gr.Textbox(label="Speech Type Name")
|
330 |
+
delete_btn = gr.Button("Delete Type", variant="secondary")
|
331 |
+
insert_btn = gr.Button("Insert Label", variant="secondary")
|
332 |
+
audio_input = gr.Audio(label="Reference Audio", type="filepath")
|
333 |
+
ref_text_input = gr.Textbox(label="Reference Text", lines=2)
|
334 |
+
speech_type_rows.append(row)
|
335 |
+
speech_type_names.append(name_input)
|
336 |
+
speech_type_audios.append(audio_input)
|
337 |
+
speech_type_ref_texts.append(ref_text_input)
|
338 |
+
speech_type_delete_btns.append(delete_btn)
|
339 |
+
speech_type_insert_btns.append(insert_btn)
|
340 |
+
|
341 |
+
# Button to add speech type
|
342 |
+
add_speech_type_btn = gr.Button("Add Speech Type")
|
343 |
+
|
344 |
+
# Keep track of current number of speech types
|
345 |
+
speech_type_count = gr.State(value=1)
|
346 |
+
|
347 |
+
# Function to add a speech type
|
348 |
+
def add_speech_type_fn(speech_type_count):
|
349 |
+
if speech_type_count < max_speech_types:
|
350 |
+
speech_type_count += 1
|
351 |
+
# Prepare updates for the rows
|
352 |
+
row_updates = []
|
353 |
+
for i in range(1, max_speech_types):
|
354 |
+
if i < speech_type_count:
|
355 |
+
row_updates.append(gr.update(visible=True))
|
356 |
+
else:
|
357 |
+
row_updates.append(gr.update())
|
358 |
+
else:
|
359 |
+
# Optionally, show a warning
|
360 |
+
row_updates = [gr.update() for _ in range(1, max_speech_types)]
|
361 |
+
return [speech_type_count] + row_updates
|
362 |
+
|
363 |
+
add_speech_type_btn.click(
|
364 |
+
add_speech_type_fn, inputs=speech_type_count, outputs=[speech_type_count] + speech_type_rows
|
365 |
+
)
|
366 |
+
|
367 |
+
# Function to delete a speech type
|
368 |
+
def make_delete_speech_type_fn(index):
|
369 |
+
def delete_speech_type_fn(speech_type_count):
|
370 |
+
# Prepare updates
|
371 |
+
row_updates = []
|
372 |
+
|
373 |
+
for i in range(1, max_speech_types):
|
374 |
+
if i == index:
|
375 |
+
row_updates.append(gr.update(visible=False))
|
376 |
+
else:
|
377 |
+
row_updates.append(gr.update())
|
378 |
+
|
379 |
+
speech_type_count = max(1, speech_type_count)
|
380 |
+
|
381 |
+
return [speech_type_count] + row_updates
|
382 |
+
|
383 |
+
return delete_speech_type_fn
|
384 |
+
|
385 |
+
# Update delete button clicks
|
386 |
+
for i, delete_btn in enumerate(speech_type_delete_btns):
|
387 |
+
delete_fn = make_delete_speech_type_fn(i)
|
388 |
+
delete_btn.click(delete_fn, inputs=speech_type_count, outputs=[speech_type_count] + speech_type_rows)
|
389 |
+
|
390 |
+
# Text input for the prompt
|
391 |
+
gen_text_input_multistyle = gr.Textbox(
|
392 |
+
label="Text to Generate",
|
393 |
+
lines=10,
|
394 |
+
placeholder="Enter the script with speaker names (or emotion types) at the start of each block, e.g.:\n\n{Regular} Hello, I'd like to order a sandwich please.\n{Surprised} What do you mean you're out of bread?\n{Sad} I really wanted a sandwich though...\n{Angry} You know what, darn you and your little shop!\n{Whisper} I'll just go back home and cry now.\n{Shouting} Why me?!",
|
395 |
+
)
|
396 |
+
|
397 |
+
def make_insert_speech_type_fn(index):
|
398 |
+
def insert_speech_type_fn(current_text, speech_type_name):
|
399 |
+
current_text = current_text or ""
|
400 |
+
speech_type_name = speech_type_name or "None"
|
401 |
+
updated_text = current_text + f"{{{speech_type_name}}} "
|
402 |
+
return gr.update(value=updated_text)
|
403 |
+
|
404 |
+
return insert_speech_type_fn
|
405 |
+
|
406 |
+
for i, insert_btn in enumerate(speech_type_insert_btns):
|
407 |
+
insert_fn = make_insert_speech_type_fn(i)
|
408 |
+
insert_btn.click(
|
409 |
+
insert_fn,
|
410 |
+
inputs=[gen_text_input_multistyle, speech_type_names[i]],
|
411 |
+
outputs=gen_text_input_multistyle,
|
412 |
+
)
|
413 |
+
|
414 |
+
with gr.Accordion("Advanced Settings", open=False):
|
415 |
+
remove_silence_multistyle = gr.Checkbox(
|
416 |
+
label="Remove Silences",
|
417 |
+
value=True,
|
418 |
+
)
|
419 |
+
|
420 |
+
# Generate button
|
421 |
+
generate_multistyle_btn = gr.Button("Generate Multi-Style Speech", variant="primary")
|
422 |
+
|
423 |
+
# Output audio
|
424 |
+
audio_output_multistyle = gr.Audio(label="Synthesized Audio")
|
425 |
+
|
426 |
+
@gpu_decorator
|
427 |
+
def generate_multistyle_speech(
|
428 |
+
gen_text,
|
429 |
+
*args,
|
430 |
+
):
|
431 |
+
speech_type_names_list = args[:max_speech_types]
|
432 |
+
speech_type_audios_list = args[max_speech_types : 2 * max_speech_types]
|
433 |
+
speech_type_ref_texts_list = args[2 * max_speech_types : 3 * max_speech_types]
|
434 |
+
remove_silence = args[3 * max_speech_types]
|
435 |
+
# Collect the speech types and their audios into a dict
|
436 |
+
speech_types = OrderedDict()
|
437 |
+
|
438 |
+
ref_text_idx = 0
|
439 |
+
for name_input, audio_input, ref_text_input in zip(
|
440 |
+
speech_type_names_list, speech_type_audios_list, speech_type_ref_texts_list
|
441 |
+
):
|
442 |
+
if name_input and audio_input:
|
443 |
+
speech_types[name_input] = {"audio": audio_input, "ref_text": ref_text_input}
|
444 |
+
else:
|
445 |
+
speech_types[f"@{ref_text_idx}@"] = {"audio": "", "ref_text": ""}
|
446 |
+
ref_text_idx += 1
|
447 |
+
|
448 |
+
# Parse the gen_text into segments
|
449 |
+
segments = parse_speechtypes_text(gen_text)
|
450 |
+
|
451 |
+
# For each segment, generate speech
|
452 |
+
generated_audio_segments = []
|
453 |
+
current_style = "Regular"
|
454 |
+
|
455 |
+
for segment in segments:
|
456 |
+
style = segment["style"]
|
457 |
+
text = segment["text"]
|
458 |
+
|
459 |
+
if style in speech_types:
|
460 |
+
current_style = style
|
461 |
+
else:
|
462 |
+
# If style not available, default to Regular
|
463 |
+
current_style = "Regular"
|
464 |
+
|
465 |
+
ref_audio = speech_types[current_style]["audio"]
|
466 |
+
ref_text = speech_types[current_style].get("ref_text", "")
|
467 |
+
|
468 |
+
# Generate speech for this segment
|
469 |
+
audio_out, _, ref_text_out = infer(
|
470 |
+
ref_audio, ref_text, text, tts_model_choice, remove_silence, 0, show_info=print
|
471 |
+
) # show_info=print no pull to top when generating
|
472 |
+
sr, audio_data = audio_out
|
473 |
+
|
474 |
+
generated_audio_segments.append(audio_data)
|
475 |
+
speech_types[current_style]["ref_text"] = ref_text_out
|
476 |
+
|
477 |
+
# Concatenate all audio segments
|
478 |
+
if generated_audio_segments:
|
479 |
+
final_audio_data = np.concatenate(generated_audio_segments)
|
480 |
+
return [(sr, final_audio_data)] + [
|
481 |
+
gr.update(value=speech_types[style]["ref_text"]) for style in speech_types
|
482 |
+
]
|
483 |
+
else:
|
484 |
+
gr.Warning("No audio generated.")
|
485 |
+
return [None] + [gr.update(value=speech_types[style]["ref_text"]) for style in speech_types]
|
486 |
+
|
487 |
+
generate_multistyle_btn.click(
|
488 |
+
generate_multistyle_speech,
|
489 |
+
inputs=[
|
490 |
+
gen_text_input_multistyle,
|
491 |
+
]
|
492 |
+
+ speech_type_names
|
493 |
+
+ speech_type_audios
|
494 |
+
+ speech_type_ref_texts
|
495 |
+
+ [
|
496 |
+
remove_silence_multistyle,
|
497 |
+
],
|
498 |
+
outputs=[audio_output_multistyle] + speech_type_ref_texts,
|
499 |
+
)
|
500 |
+
|
501 |
+
# Validation function to disable Generate button if speech types are missing
|
502 |
+
def validate_speech_types(gen_text, regular_name, *args):
|
503 |
+
speech_type_names_list = args[:max_speech_types]
|
504 |
+
|
505 |
+
# Collect the speech types names
|
506 |
+
speech_types_available = set()
|
507 |
+
if regular_name:
|
508 |
+
speech_types_available.add(regular_name)
|
509 |
+
for name_input in speech_type_names_list:
|
510 |
+
if name_input:
|
511 |
+
speech_types_available.add(name_input)
|
512 |
+
|
513 |
+
# Parse the gen_text to get the speech types used
|
514 |
+
segments = parse_speechtypes_text(gen_text)
|
515 |
+
speech_types_in_text = set(segment["style"] for segment in segments)
|
516 |
+
|
517 |
+
# Check if all speech types in text are available
|
518 |
+
missing_speech_types = speech_types_in_text - speech_types_available
|
519 |
+
|
520 |
+
if missing_speech_types:
|
521 |
+
# Disable the generate button
|
522 |
+
return gr.update(interactive=False)
|
523 |
+
else:
|
524 |
+
# Enable the generate button
|
525 |
+
return gr.update(interactive=True)
|
526 |
+
|
527 |
+
gen_text_input_multistyle.change(
|
528 |
+
validate_speech_types,
|
529 |
+
inputs=[gen_text_input_multistyle, regular_name] + speech_type_names,
|
530 |
+
outputs=generate_multistyle_btn,
|
531 |
+
)
|
532 |
+
|
533 |
+
|
534 |
+
with gr.Blocks() as app_chat:
|
535 |
+
gr.Markdown(
|
536 |
+
"""
|
537 |
+
# Voice Chat
|
538 |
+
Have a conversation with an AI using your reference voice!
|
539 |
+
1. Upload a reference audio clip and optionally its transcript.
|
540 |
+
2. Load the chat model.
|
541 |
+
3. Record your message through your microphone.
|
542 |
+
4. The AI will respond using the reference voice.
|
543 |
+
"""
|
544 |
+
)
|
545 |
+
|
546 |
+
if not USING_SPACES:
|
547 |
+
load_chat_model_btn = gr.Button("Load Chat Model", variant="primary")
|
548 |
+
|
549 |
+
chat_interface_container = gr.Column(visible=False)
|
550 |
+
|
551 |
+
@gpu_decorator
|
552 |
+
def load_chat_model():
|
553 |
+
global chat_model_state, chat_tokenizer_state
|
554 |
+
if chat_model_state is None:
|
555 |
+
show_info = gr.Info
|
556 |
+
show_info("Loading chat model...")
|
557 |
+
model_name = "Qwen/Qwen2.5-3B-Instruct"
|
558 |
+
chat_model_state = AutoModelForCausalLM.from_pretrained(
|
559 |
+
model_name, torch_dtype="auto", device_map="auto"
|
560 |
+
)
|
561 |
+
chat_tokenizer_state = AutoTokenizer.from_pretrained(model_name)
|
562 |
+
show_info("Chat model loaded.")
|
563 |
+
|
564 |
+
return gr.update(visible=False), gr.update(visible=True)
|
565 |
+
|
566 |
+
load_chat_model_btn.click(load_chat_model, outputs=[load_chat_model_btn, chat_interface_container])
|
567 |
+
|
568 |
+
else:
|
569 |
+
chat_interface_container = gr.Column()
|
570 |
+
|
571 |
+
if chat_model_state is None:
|
572 |
+
model_name = "Qwen/Qwen2.5-3B-Instruct"
|
573 |
+
chat_model_state = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
|
574 |
+
chat_tokenizer_state = AutoTokenizer.from_pretrained(model_name)
|
575 |
+
|
576 |
+
with chat_interface_container:
|
577 |
+
with gr.Row():
|
578 |
+
with gr.Column():
|
579 |
+
ref_audio_chat = gr.Audio(label="Reference Audio", type="filepath")
|
580 |
+
with gr.Column():
|
581 |
+
with gr.Accordion("Advanced Settings", open=False):
|
582 |
+
remove_silence_chat = gr.Checkbox(
|
583 |
+
label="Remove Silences",
|
584 |
+
value=True,
|
585 |
+
)
|
586 |
+
ref_text_chat = gr.Textbox(
|
587 |
+
label="Reference Text",
|
588 |
+
info="Optional: Leave blank to auto-transcribe",
|
589 |
+
lines=2,
|
590 |
+
)
|
591 |
+
system_prompt_chat = gr.Textbox(
|
592 |
+
label="System Prompt",
|
593 |
+
value="You are not an AI assistant, you are whoever the user says you are. You must stay in character. Keep your responses concise since they will be spoken out loud.",
|
594 |
+
lines=2,
|
595 |
+
)
|
596 |
+
|
597 |
+
chatbot_interface = gr.Chatbot(label="Conversation")
|
598 |
+
|
599 |
+
with gr.Row():
|
600 |
+
with gr.Column():
|
601 |
+
audio_input_chat = gr.Microphone(
|
602 |
+
label="Speak your message",
|
603 |
+
type="filepath",
|
604 |
+
)
|
605 |
+
audio_output_chat = gr.Audio(autoplay=True)
|
606 |
+
with gr.Column():
|
607 |
+
text_input_chat = gr.Textbox(
|
608 |
+
label="Type your message",
|
609 |
+
lines=1,
|
610 |
+
)
|
611 |
+
send_btn_chat = gr.Button("Send Message")
|
612 |
+
clear_btn_chat = gr.Button("Clear Conversation")
|
613 |
+
|
614 |
+
conversation_state = gr.State(
|
615 |
+
value=[
|
616 |
+
{
|
617 |
+
"role": "system",
|
618 |
+
"content": "You are not an AI assistant, you are whoever the user says you are. You must stay in character. Keep your responses concise since they will be spoken out loud.",
|
619 |
+
}
|
620 |
+
]
|
621 |
+
)
|
622 |
+
|
623 |
+
# Modify process_audio_input to use model and tokenizer from state
|
624 |
+
@gpu_decorator
|
625 |
+
def process_audio_input(audio_path, text, history, conv_state):
|
626 |
+
"""Handle audio or text input from user"""
|
627 |
+
|
628 |
+
if not audio_path and not text.strip():
|
629 |
+
return history, conv_state, ""
|
630 |
+
|
631 |
+
if audio_path:
|
632 |
+
text = preprocess_ref_audio_text(audio_path, text)[1]
|
633 |
+
|
634 |
+
if not text.strip():
|
635 |
+
return history, conv_state, ""
|
636 |
+
|
637 |
+
conv_state.append({"role": "user", "content": text})
|
638 |
+
history.append((text, None))
|
639 |
+
|
640 |
+
response = generate_response(conv_state, chat_model_state, chat_tokenizer_state)
|
641 |
+
|
642 |
+
conv_state.append({"role": "assistant", "content": response})
|
643 |
+
history[-1] = (text, response)
|
644 |
+
|
645 |
+
return history, conv_state, ""
|
646 |
+
|
647 |
+
@gpu_decorator
|
648 |
+
def generate_audio_response(history, ref_audio, ref_text, remove_silence):
|
649 |
+
"""Generate TTS audio for AI response"""
|
650 |
+
if not history or not ref_audio:
|
651 |
+
return None
|
652 |
+
|
653 |
+
last_user_message, last_ai_response = history[-1]
|
654 |
+
if not last_ai_response:
|
655 |
+
return None
|
656 |
+
|
657 |
+
audio_result, _, ref_text_out = infer(
|
658 |
+
ref_audio,
|
659 |
+
ref_text,
|
660 |
+
last_ai_response,
|
661 |
+
tts_model_choice,
|
662 |
+
remove_silence,
|
663 |
+
cross_fade_duration=0.15,
|
664 |
+
speed=1.0,
|
665 |
+
show_info=print, # show_info=print no pull to top when generating
|
666 |
+
)
|
667 |
+
return audio_result, gr.update(value=ref_text_out)
|
668 |
+
|
669 |
+
def clear_conversation():
|
670 |
+
"""Reset the conversation"""
|
671 |
+
return [], [
|
672 |
+
{
|
673 |
+
"role": "system",
|
674 |
+
"content": "You are not an AI assistant, you are whoever the user says you are. You must stay in character. Keep your responses concise since they will be spoken out loud.",
|
675 |
+
}
|
676 |
+
]
|
677 |
+
|
678 |
+
def update_system_prompt(new_prompt):
|
679 |
+
"""Update the system prompt and reset the conversation"""
|
680 |
+
new_conv_state = [{"role": "system", "content": new_prompt}]
|
681 |
+
return [], new_conv_state
|
682 |
+
|
683 |
+
# Handle audio input
|
684 |
+
audio_input_chat.stop_recording(
|
685 |
+
process_audio_input,
|
686 |
+
inputs=[audio_input_chat, text_input_chat, chatbot_interface, conversation_state],
|
687 |
+
outputs=[chatbot_interface, conversation_state],
|
688 |
+
).then(
|
689 |
+
generate_audio_response,
|
690 |
+
inputs=[chatbot_interface, ref_audio_chat, ref_text_chat, remove_silence_chat],
|
691 |
+
outputs=[audio_output_chat, ref_text_chat],
|
692 |
+
).then(
|
693 |
+
lambda: None,
|
694 |
+
None,
|
695 |
+
audio_input_chat,
|
696 |
+
)
|
697 |
+
|
698 |
+
# Handle text input
|
699 |
+
text_input_chat.submit(
|
700 |
+
process_audio_input,
|
701 |
+
inputs=[audio_input_chat, text_input_chat, chatbot_interface, conversation_state],
|
702 |
+
outputs=[chatbot_interface, conversation_state],
|
703 |
+
).then(
|
704 |
+
generate_audio_response,
|
705 |
+
inputs=[chatbot_interface, ref_audio_chat, ref_text_chat, remove_silence_chat],
|
706 |
+
outputs=[audio_output_chat, ref_text_chat],
|
707 |
+
).then(
|
708 |
+
lambda: None,
|
709 |
+
None,
|
710 |
+
text_input_chat,
|
711 |
+
)
|
712 |
+
|
713 |
+
# Handle send button
|
714 |
+
send_btn_chat.click(
|
715 |
+
process_audio_input,
|
716 |
+
inputs=[audio_input_chat, text_input_chat, chatbot_interface, conversation_state],
|
717 |
+
outputs=[chatbot_interface, conversation_state],
|
718 |
+
).then(
|
719 |
+
generate_audio_response,
|
720 |
+
inputs=[chatbot_interface, ref_audio_chat, ref_text_chat, remove_silence_chat],
|
721 |
+
outputs=[audio_output_chat, ref_text_chat],
|
722 |
+
).then(
|
723 |
+
lambda: None,
|
724 |
+
None,
|
725 |
+
text_input_chat,
|
726 |
+
)
|
727 |
+
|
728 |
+
# Handle clear button
|
729 |
+
clear_btn_chat.click(
|
730 |
+
clear_conversation,
|
731 |
+
outputs=[chatbot_interface, conversation_state],
|
732 |
+
)
|
733 |
+
|
734 |
+
# Handle system prompt change and reset conversation
|
735 |
+
system_prompt_chat.change(
|
736 |
+
update_system_prompt,
|
737 |
+
inputs=system_prompt_chat,
|
738 |
+
outputs=[chatbot_interface, conversation_state],
|
739 |
+
)
|
740 |
+
|
741 |
+
|
742 |
+
with gr.Blocks() as app:
|
743 |
+
gr.Markdown(
|
744 |
+
"""
|
745 |
+
# Panchi TTS
|
746 |
+
|
747 |
+
**NOTE: Reference text will be automatically transcribed with Whisper if not provided. For best results, keep your reference clips short (<15s). Ensure the audio is fully uploaded before generating.**
|
748 |
+
"""
|
749 |
+
)
|
750 |
+
|
751 |
+
last_used_custom = files("f5_tts").joinpath("infer/.cache/last_used_custom.txt")
|
752 |
+
|
753 |
+
def load_last_used_custom():
|
754 |
+
try:
|
755 |
+
with open(last_used_custom, "r") as f:
|
756 |
+
return f.read().split(",")
|
757 |
+
except FileNotFoundError:
|
758 |
+
last_used_custom.parent.mkdir(parents=True, exist_ok=True)
|
759 |
+
return [
|
760 |
+
"hf://SWivid/F5-TTS/F5TTS_Base/model_1200000.safetensors",
|
761 |
+
"hf://SWivid/F5-TTS/F5TTS_Base/vocab.txt",
|
762 |
+
]
|
763 |
+
|
764 |
+
def switch_tts_model(new_choice):
|
765 |
+
global tts_model_choice
|
766 |
+
if new_choice == "Custom": # override in case webpage is refreshed
|
767 |
+
custom_ckpt_path, custom_vocab_path = load_last_used_custom()
|
768 |
+
tts_model_choice = ["Custom", custom_ckpt_path, custom_vocab_path]
|
769 |
+
return gr.update(visible=True, value=custom_ckpt_path), gr.update(visible=True, value=custom_vocab_path)
|
770 |
+
else:
|
771 |
+
tts_model_choice = new_choice
|
772 |
+
return gr.update(visible=False), gr.update(visible=False)
|
773 |
+
|
774 |
+
def set_custom_model(custom_ckpt_path, custom_vocab_path):
|
775 |
+
global tts_model_choice
|
776 |
+
tts_model_choice = ["Custom", custom_ckpt_path, custom_vocab_path]
|
777 |
+
with open(last_used_custom, "w") as f:
|
778 |
+
f.write(f"{custom_ckpt_path},{custom_vocab_path}")
|
779 |
+
|
780 |
+
with gr.Row():
|
781 |
+
if not USING_SPACES:
|
782 |
+
choose_tts_model = gr.Radio(
|
783 |
+
choices=[DEFAULT_TTS_MODEL, "E2-TTS", "Custom"], label="Choose TTS Model", value=DEFAULT_TTS_MODEL
|
784 |
+
)
|
785 |
+
else:
|
786 |
+
choose_tts_model = gr.Radio(
|
787 |
+
choices=[DEFAULT_TTS_MODEL, "E2-TTS"], label="Choose TTS Model", value=DEFAULT_TTS_MODEL
|
788 |
+
)
|
789 |
+
custom_ckpt_path = gr.Dropdown(
|
790 |
+
choices=["hf://SWivid/F5-TTS/F5TTS_Base/model_1200000.safetensors"],
|
791 |
+
value=load_last_used_custom()[0],
|
792 |
+
allow_custom_value=True,
|
793 |
+
label="MODEL CKPT: local_path | hf://user_id/repo_id/model_ckpt",
|
794 |
+
visible=False,
|
795 |
+
)
|
796 |
+
custom_vocab_path = gr.Dropdown(
|
797 |
+
choices=["hf://SWivid/F5-TTS/F5TTS_Base/vocab.txt"],
|
798 |
+
value=load_last_used_custom()[1],
|
799 |
+
allow_custom_value=True,
|
800 |
+
label="VOCAB FILE: local_path | hf://user_id/repo_id/vocab_file",
|
801 |
+
visible=False,
|
802 |
+
)
|
803 |
+
|
804 |
+
choose_tts_model.change(
|
805 |
+
switch_tts_model,
|
806 |
+
inputs=[choose_tts_model],
|
807 |
+
outputs=[custom_ckpt_path, custom_vocab_path],
|
808 |
+
show_progress="hidden",
|
809 |
+
)
|
810 |
+
custom_ckpt_path.change(
|
811 |
+
set_custom_model,
|
812 |
+
inputs=[custom_ckpt_path, custom_vocab_path],
|
813 |
+
show_progress="hidden",
|
814 |
+
)
|
815 |
+
custom_vocab_path.change(
|
816 |
+
set_custom_model,
|
817 |
+
inputs=[custom_ckpt_path, custom_vocab_path],
|
818 |
+
show_progress="hidden",
|
819 |
+
)
|
820 |
+
|
821 |
+
gr.TabbedInterface(
|
822 |
+
[app_tts, app_multistyle, app_chat, app_credits],
|
823 |
+
["Basic-TTS", "Multi-Speech", "Voice-Chat", "Credits"],
|
824 |
+
)
|
825 |
+
|
826 |
+
|
827 |
+
@click.command()
|
828 |
+
@click.option("--port", "-p", default=None, type=int, help="Port to run the app on")
|
829 |
+
@click.option("--host", "-H", default=None, help="Host to run the app on")
|
830 |
+
@click.option(
|
831 |
+
"--share",
|
832 |
+
"-s",
|
833 |
+
default=False,
|
834 |
+
is_flag=True,
|
835 |
+
help="Share the app via Gradio share link",
|
836 |
+
)
|
837 |
+
@click.option("--api", "-a", default=True, is_flag=True, help="Allow API access")
|
838 |
+
@click.option(
|
839 |
+
"--root_path",
|
840 |
+
"-r",
|
841 |
+
default=None,
|
842 |
+
type=str,
|
843 |
+
help='The root path (or "mount point") of the application, if it\'s not served from the root ("/") of the domain. Often used when the application is behind a reverse proxy that forwards requests to the application, e.g. set "/myapp" or full URL for application served at "https://example.com/myapp".',
|
844 |
+
)
|
845 |
+
def main(port, host, share, api, root_path):
|
846 |
+
global app
|
847 |
+
print("Starting app...")
|
848 |
+
app.queue(api_open=api).launch(server_name=host, server_port=port, share=share, show_api=api, root_path=root_path)
|
849 |
+
|
850 |
+
|
851 |
+
if __name__ == "__main__":
|
852 |
+
if not USING_SPACES:
|
853 |
+
main()
|
854 |
+
else:
|
855 |
+
app.queue().launch()
|
f5_tts/infer/infer_gradio_orig.py
ADDED
@@ -0,0 +1,853 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ruff: noqa: E402
|
2 |
+
# Above allows ruff to ignore E402: module level import not at top of file
|
3 |
+
|
4 |
+
import re
|
5 |
+
import tempfile
|
6 |
+
from collections import OrderedDict
|
7 |
+
from importlib.resources import files
|
8 |
+
|
9 |
+
import click
|
10 |
+
import gradio as gr
|
11 |
+
import numpy as np
|
12 |
+
import soundfile as sf
|
13 |
+
import torchaudio
|
14 |
+
from cached_path import cached_path
|
15 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
16 |
+
|
17 |
+
try:
|
18 |
+
import spaces
|
19 |
+
|
20 |
+
USING_SPACES = True
|
21 |
+
except ImportError:
|
22 |
+
USING_SPACES = False
|
23 |
+
|
24 |
+
|
25 |
+
def gpu_decorator(func):
|
26 |
+
if USING_SPACES:
|
27 |
+
return spaces.GPU(func)
|
28 |
+
else:
|
29 |
+
return func
|
30 |
+
|
31 |
+
|
32 |
+
from f5_tts.model import DiT, UNetT
|
33 |
+
from f5_tts.infer.utils_infer import (
|
34 |
+
load_vocoder,
|
35 |
+
load_model,
|
36 |
+
preprocess_ref_audio_text,
|
37 |
+
infer_process,
|
38 |
+
remove_silence_for_generated_wav,
|
39 |
+
save_spectrogram,
|
40 |
+
)
|
41 |
+
|
42 |
+
|
43 |
+
DEFAULT_TTS_MODEL = "F5-TTS"
|
44 |
+
tts_model_choice = DEFAULT_TTS_MODEL
|
45 |
+
|
46 |
+
|
47 |
+
# load models
|
48 |
+
|
49 |
+
vocoder = load_vocoder()
|
50 |
+
|
51 |
+
|
52 |
+
def load_f5tts(ckpt_path=str(cached_path("hf://SWivid/F5-TTS/F5TTS_Base/model_1200000.safetensors"))):
|
53 |
+
F5TTS_model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
54 |
+
|
55 |
+
ckpt_path = "/home/tts/ttsteam/repos/F5-TTS/runs/indic_langs_11/ckpt/model_336000.pt"
|
56 |
+
return load_model(DiT, F5TTS_model_cfg, ckpt_path)
|
57 |
+
|
58 |
+
|
59 |
+
def load_e2tts(ckpt_path=str(cached_path("hf://SWivid/E2-TTS/E2TTS_Base/model_1200000.safetensors"))):
|
60 |
+
E2TTS_model_cfg = dict(dim=1024, depth=24, heads=16, ff_mult=4)
|
61 |
+
return load_model(UNetT, E2TTS_model_cfg, ckpt_path)
|
62 |
+
|
63 |
+
|
64 |
+
def load_custom(ckpt_path: str, vocab_path="", model_cfg=None):
|
65 |
+
ckpt_path, vocab_path = ckpt_path.strip(), vocab_path.strip()
|
66 |
+
if ckpt_path.startswith("hf://"):
|
67 |
+
ckpt_path = str(cached_path(ckpt_path))
|
68 |
+
if vocab_path.startswith("hf://"):
|
69 |
+
vocab_path = str(cached_path(vocab_path))
|
70 |
+
if model_cfg is None:
|
71 |
+
model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
72 |
+
return load_model(DiT, model_cfg, ckpt_path, vocab_file=vocab_path)
|
73 |
+
|
74 |
+
|
75 |
+
F5TTS_ema_model = load_f5tts()
|
76 |
+
E2TTS_ema_model = load_e2tts() if USING_SPACES else None
|
77 |
+
custom_ema_model, pre_custom_path = None, ""
|
78 |
+
|
79 |
+
chat_model_state = None
|
80 |
+
chat_tokenizer_state = None
|
81 |
+
|
82 |
+
|
83 |
+
@gpu_decorator
|
84 |
+
def generate_response(messages, model, tokenizer):
|
85 |
+
"""Generate response using Qwen"""
|
86 |
+
text = tokenizer.apply_chat_template(
|
87 |
+
messages,
|
88 |
+
tokenize=False,
|
89 |
+
add_generation_prompt=True,
|
90 |
+
)
|
91 |
+
|
92 |
+
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
93 |
+
generated_ids = model.generate(
|
94 |
+
**model_inputs,
|
95 |
+
max_new_tokens=512,
|
96 |
+
temperature=0.7,
|
97 |
+
top_p=0.95,
|
98 |
+
)
|
99 |
+
|
100 |
+
generated_ids = [
|
101 |
+
output_ids[len(input_ids) :] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
102 |
+
]
|
103 |
+
return tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
104 |
+
|
105 |
+
|
106 |
+
@gpu_decorator
|
107 |
+
def infer(
|
108 |
+
ref_audio_orig, ref_text, gen_text, model, remove_silence, cross_fade_duration=0.15, speed=1, show_info=gr.Info
|
109 |
+
):
|
110 |
+
ref_audio, ref_text = preprocess_ref_audio_text(ref_audio_orig, ref_text, show_info=show_info)
|
111 |
+
|
112 |
+
if model == "F5-TTS":
|
113 |
+
ema_model = F5TTS_ema_model
|
114 |
+
elif model == "E2-TTS":
|
115 |
+
global E2TTS_ema_model
|
116 |
+
if E2TTS_ema_model is None:
|
117 |
+
show_info("Loading E2-TTS model...")
|
118 |
+
E2TTS_ema_model = load_e2tts()
|
119 |
+
ema_model = E2TTS_ema_model
|
120 |
+
elif isinstance(model, list) and model[0] == "Custom":
|
121 |
+
assert not USING_SPACES, "Only official checkpoints allowed in Spaces."
|
122 |
+
global custom_ema_model, pre_custom_path
|
123 |
+
if pre_custom_path != model[1]:
|
124 |
+
show_info("Loading Custom TTS model...")
|
125 |
+
custom_ema_model = load_custom(model[1], vocab_path=model[2])
|
126 |
+
pre_custom_path = model[1]
|
127 |
+
ema_model = custom_ema_model
|
128 |
+
|
129 |
+
final_wave, final_sample_rate, combined_spectrogram = infer_process(
|
130 |
+
ref_audio,
|
131 |
+
ref_text,
|
132 |
+
gen_text,
|
133 |
+
ema_model,
|
134 |
+
vocoder,
|
135 |
+
cross_fade_duration=cross_fade_duration,
|
136 |
+
speed=speed,
|
137 |
+
show_info=show_info,
|
138 |
+
progress=gr.Progress(),
|
139 |
+
)
|
140 |
+
|
141 |
+
# Remove silence
|
142 |
+
if remove_silence:
|
143 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
|
144 |
+
sf.write(f.name, final_wave, final_sample_rate)
|
145 |
+
remove_silence_for_generated_wav(f.name)
|
146 |
+
final_wave, _ = torchaudio.load(f.name)
|
147 |
+
final_wave = final_wave.squeeze().cpu().numpy()
|
148 |
+
|
149 |
+
# Save the spectrogram
|
150 |
+
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp_spectrogram:
|
151 |
+
spectrogram_path = tmp_spectrogram.name
|
152 |
+
save_spectrogram(combined_spectrogram, spectrogram_path)
|
153 |
+
|
154 |
+
return (final_sample_rate, final_wave), spectrogram_path, ref_text
|
155 |
+
|
156 |
+
|
157 |
+
with gr.Blocks() as app_credits:
|
158 |
+
gr.Markdown("""
|
159 |
+
# Credits
|
160 |
+
|
161 |
+
* [mrfakename](https://github.com/fakerybakery) for the original [online demo](https://huggingface.co/spaces/mrfakename/E2-F5-TTS)
|
162 |
+
* [RootingInLoad](https://github.com/RootingInLoad) for initial chunk generation and podcast app exploration
|
163 |
+
* [jpgallegoar](https://github.com/jpgallegoar) for multiple speech-type generation & voice chat
|
164 |
+
""")
|
165 |
+
with gr.Blocks() as app_tts:
|
166 |
+
gr.Markdown("# Batched TTS")
|
167 |
+
ref_audio_input = gr.Audio(label="Reference Audio", type="filepath")
|
168 |
+
gen_text_input = gr.Textbox(label="Text to Generate", lines=10)
|
169 |
+
generate_btn = gr.Button("Synthesize", variant="primary")
|
170 |
+
with gr.Accordion("Advanced Settings", open=False):
|
171 |
+
ref_text_input = gr.Textbox(
|
172 |
+
label="Reference Text",
|
173 |
+
info="Leave blank to automatically transcribe the reference audio. If you enter text it will override automatic transcription.",
|
174 |
+
lines=2,
|
175 |
+
)
|
176 |
+
remove_silence = gr.Checkbox(
|
177 |
+
label="Remove Silences",
|
178 |
+
info="The model tends to produce silences, especially on longer audio. We can manually remove silences if needed. Note that this is an experimental feature and may produce strange results. This will also increase generation time.",
|
179 |
+
value=False,
|
180 |
+
)
|
181 |
+
speed_slider = gr.Slider(
|
182 |
+
label="Speed",
|
183 |
+
minimum=0.3,
|
184 |
+
maximum=2.0,
|
185 |
+
value=1.0,
|
186 |
+
step=0.1,
|
187 |
+
info="Adjust the speed of the audio.",
|
188 |
+
)
|
189 |
+
cross_fade_duration_slider = gr.Slider(
|
190 |
+
label="Cross-Fade Duration (s)",
|
191 |
+
minimum=0.0,
|
192 |
+
maximum=1.0,
|
193 |
+
value=0.15,
|
194 |
+
step=0.01,
|
195 |
+
info="Set the duration of the cross-fade between audio clips.",
|
196 |
+
)
|
197 |
+
|
198 |
+
audio_output = gr.Audio(label="Synthesized Audio")
|
199 |
+
spectrogram_output = gr.Image(label="Spectrogram")
|
200 |
+
|
201 |
+
@gpu_decorator
|
202 |
+
def basic_tts(
|
203 |
+
ref_audio_input,
|
204 |
+
ref_text_input,
|
205 |
+
gen_text_input,
|
206 |
+
remove_silence,
|
207 |
+
cross_fade_duration_slider,
|
208 |
+
speed_slider,
|
209 |
+
):
|
210 |
+
audio_out, spectrogram_path, ref_text_out = infer(
|
211 |
+
ref_audio_input,
|
212 |
+
ref_text_input,
|
213 |
+
gen_text_input,
|
214 |
+
tts_model_choice,
|
215 |
+
remove_silence,
|
216 |
+
cross_fade_duration_slider,
|
217 |
+
speed_slider,
|
218 |
+
)
|
219 |
+
return audio_out, spectrogram_path, gr.update(value=ref_text_out)
|
220 |
+
|
221 |
+
generate_btn.click(
|
222 |
+
basic_tts,
|
223 |
+
inputs=[
|
224 |
+
ref_audio_input,
|
225 |
+
ref_text_input,
|
226 |
+
gen_text_input,
|
227 |
+
remove_silence,
|
228 |
+
cross_fade_duration_slider,
|
229 |
+
speed_slider,
|
230 |
+
],
|
231 |
+
outputs=[audio_output, spectrogram_output, ref_text_input],
|
232 |
+
)
|
233 |
+
|
234 |
+
|
235 |
+
def parse_speechtypes_text(gen_text):
|
236 |
+
# Pattern to find {speechtype}
|
237 |
+
pattern = r"\{(.*?)\}"
|
238 |
+
|
239 |
+
# Split the text by the pattern
|
240 |
+
tokens = re.split(pattern, gen_text)
|
241 |
+
|
242 |
+
segments = []
|
243 |
+
|
244 |
+
current_style = "Regular"
|
245 |
+
|
246 |
+
for i in range(len(tokens)):
|
247 |
+
if i % 2 == 0:
|
248 |
+
# This is text
|
249 |
+
text = tokens[i].strip()
|
250 |
+
if text:
|
251 |
+
segments.append({"style": current_style, "text": text})
|
252 |
+
else:
|
253 |
+
# This is style
|
254 |
+
style = tokens[i].strip()
|
255 |
+
current_style = style
|
256 |
+
|
257 |
+
return segments
|
258 |
+
|
259 |
+
|
260 |
+
with gr.Blocks() as app_multistyle:
|
261 |
+
# New section for multistyle generation
|
262 |
+
gr.Markdown(
|
263 |
+
"""
|
264 |
+
# Multiple Speech-Type Generation
|
265 |
+
|
266 |
+
This section allows you to generate multiple speech types or multiple people's voices. Enter your text in the format shown below, and the system will generate speech using the appropriate type. If unspecified, the model will use the regular speech type. The current speech type will be used until the next speech type is specified.
|
267 |
+
"""
|
268 |
+
)
|
269 |
+
|
270 |
+
with gr.Row():
|
271 |
+
gr.Markdown(
|
272 |
+
"""
|
273 |
+
**Example Input:**
|
274 |
+
{Regular} Hello, I'd like to order a sandwich please.
|
275 |
+
{Surprised} What do you mean you're out of bread?
|
276 |
+
{Sad} I really wanted a sandwich though...
|
277 |
+
{Angry} You know what, darn you and your little shop!
|
278 |
+
{Whisper} I'll just go back home and cry now.
|
279 |
+
{Shouting} Why me?!
|
280 |
+
"""
|
281 |
+
)
|
282 |
+
|
283 |
+
gr.Markdown(
|
284 |
+
"""
|
285 |
+
**Example Input 2:**
|
286 |
+
{Speaker1_Happy} Hello, I'd like to order a sandwich please.
|
287 |
+
{Speaker2_Regular} Sorry, we're out of bread.
|
288 |
+
{Speaker1_Sad} I really wanted a sandwich though...
|
289 |
+
{Speaker2_Whisper} I'll give you the last one I was hiding.
|
290 |
+
"""
|
291 |
+
)
|
292 |
+
|
293 |
+
gr.Markdown(
|
294 |
+
"Upload different audio clips for each speech type. The first speech type is mandatory. You can add additional speech types by clicking the 'Add Speech Type' button."
|
295 |
+
)
|
296 |
+
|
297 |
+
# Regular speech type (mandatory)
|
298 |
+
with gr.Row():
|
299 |
+
with gr.Column():
|
300 |
+
regular_name = gr.Textbox(value="Regular", label="Speech Type Name")
|
301 |
+
regular_insert = gr.Button("Insert Label", variant="secondary")
|
302 |
+
regular_audio = gr.Audio(label="Regular Reference Audio", type="filepath")
|
303 |
+
regular_ref_text = gr.Textbox(label="Reference Text (Regular)", lines=2)
|
304 |
+
|
305 |
+
# Regular speech type (max 100)
|
306 |
+
max_speech_types = 100
|
307 |
+
speech_type_rows = [] # 99
|
308 |
+
speech_type_names = [regular_name] # 100
|
309 |
+
speech_type_audios = [regular_audio] # 100
|
310 |
+
speech_type_ref_texts = [regular_ref_text] # 100
|
311 |
+
speech_type_delete_btns = [] # 99
|
312 |
+
speech_type_insert_btns = [regular_insert] # 100
|
313 |
+
|
314 |
+
# Additional speech types (99 more)
|
315 |
+
for i in range(max_speech_types - 1):
|
316 |
+
with gr.Row(visible=False) as row:
|
317 |
+
with gr.Column():
|
318 |
+
name_input = gr.Textbox(label="Speech Type Name")
|
319 |
+
delete_btn = gr.Button("Delete Type", variant="secondary")
|
320 |
+
insert_btn = gr.Button("Insert Label", variant="secondary")
|
321 |
+
audio_input = gr.Audio(label="Reference Audio", type="filepath")
|
322 |
+
ref_text_input = gr.Textbox(label="Reference Text", lines=2)
|
323 |
+
speech_type_rows.append(row)
|
324 |
+
speech_type_names.append(name_input)
|
325 |
+
speech_type_audios.append(audio_input)
|
326 |
+
speech_type_ref_texts.append(ref_text_input)
|
327 |
+
speech_type_delete_btns.append(delete_btn)
|
328 |
+
speech_type_insert_btns.append(insert_btn)
|
329 |
+
|
330 |
+
# Button to add speech type
|
331 |
+
add_speech_type_btn = gr.Button("Add Speech Type")
|
332 |
+
|
333 |
+
# Keep track of current number of speech types
|
334 |
+
speech_type_count = gr.State(value=1)
|
335 |
+
|
336 |
+
# Function to add a speech type
|
337 |
+
def add_speech_type_fn(speech_type_count):
|
338 |
+
if speech_type_count < max_speech_types:
|
339 |
+
speech_type_count += 1
|
340 |
+
# Prepare updates for the rows
|
341 |
+
row_updates = []
|
342 |
+
for i in range(1, max_speech_types):
|
343 |
+
if i < speech_type_count:
|
344 |
+
row_updates.append(gr.update(visible=True))
|
345 |
+
else:
|
346 |
+
row_updates.append(gr.update())
|
347 |
+
else:
|
348 |
+
# Optionally, show a warning
|
349 |
+
row_updates = [gr.update() for _ in range(1, max_speech_types)]
|
350 |
+
return [speech_type_count] + row_updates
|
351 |
+
|
352 |
+
add_speech_type_btn.click(
|
353 |
+
add_speech_type_fn, inputs=speech_type_count, outputs=[speech_type_count] + speech_type_rows
|
354 |
+
)
|
355 |
+
|
356 |
+
# Function to delete a speech type
|
357 |
+
def make_delete_speech_type_fn(index):
|
358 |
+
def delete_speech_type_fn(speech_type_count):
|
359 |
+
# Prepare updates
|
360 |
+
row_updates = []
|
361 |
+
|
362 |
+
for i in range(1, max_speech_types):
|
363 |
+
if i == index:
|
364 |
+
row_updates.append(gr.update(visible=False))
|
365 |
+
else:
|
366 |
+
row_updates.append(gr.update())
|
367 |
+
|
368 |
+
speech_type_count = max(1, speech_type_count)
|
369 |
+
|
370 |
+
return [speech_type_count] + row_updates
|
371 |
+
|
372 |
+
return delete_speech_type_fn
|
373 |
+
|
374 |
+
# Update delete button clicks
|
375 |
+
for i, delete_btn in enumerate(speech_type_delete_btns):
|
376 |
+
delete_fn = make_delete_speech_type_fn(i)
|
377 |
+
delete_btn.click(delete_fn, inputs=speech_type_count, outputs=[speech_type_count] + speech_type_rows)
|
378 |
+
|
379 |
+
# Text input for the prompt
|
380 |
+
gen_text_input_multistyle = gr.Textbox(
|
381 |
+
label="Text to Generate",
|
382 |
+
lines=10,
|
383 |
+
placeholder="Enter the script with speaker names (or emotion types) at the start of each block, e.g.:\n\n{Regular} Hello, I'd like to order a sandwich please.\n{Surprised} What do you mean you're out of bread?\n{Sad} I really wanted a sandwich though...\n{Angry} You know what, darn you and your little shop!\n{Whisper} I'll just go back home and cry now.\n{Shouting} Why me?!",
|
384 |
+
)
|
385 |
+
|
386 |
+
def make_insert_speech_type_fn(index):
|
387 |
+
def insert_speech_type_fn(current_text, speech_type_name):
|
388 |
+
current_text = current_text or ""
|
389 |
+
speech_type_name = speech_type_name or "None"
|
390 |
+
updated_text = current_text + f"{{{speech_type_name}}} "
|
391 |
+
return gr.update(value=updated_text)
|
392 |
+
|
393 |
+
return insert_speech_type_fn
|
394 |
+
|
395 |
+
for i, insert_btn in enumerate(speech_type_insert_btns):
|
396 |
+
insert_fn = make_insert_speech_type_fn(i)
|
397 |
+
insert_btn.click(
|
398 |
+
insert_fn,
|
399 |
+
inputs=[gen_text_input_multistyle, speech_type_names[i]],
|
400 |
+
outputs=gen_text_input_multistyle,
|
401 |
+
)
|
402 |
+
|
403 |
+
with gr.Accordion("Advanced Settings", open=False):
|
404 |
+
remove_silence_multistyle = gr.Checkbox(
|
405 |
+
label="Remove Silences",
|
406 |
+
value=True,
|
407 |
+
)
|
408 |
+
|
409 |
+
# Generate button
|
410 |
+
generate_multistyle_btn = gr.Button("Generate Multi-Style Speech", variant="primary")
|
411 |
+
|
412 |
+
# Output audio
|
413 |
+
audio_output_multistyle = gr.Audio(label="Synthesized Audio")
|
414 |
+
|
415 |
+
@gpu_decorator
|
416 |
+
def generate_multistyle_speech(
|
417 |
+
gen_text,
|
418 |
+
*args,
|
419 |
+
):
|
420 |
+
speech_type_names_list = args[:max_speech_types]
|
421 |
+
speech_type_audios_list = args[max_speech_types : 2 * max_speech_types]
|
422 |
+
speech_type_ref_texts_list = args[2 * max_speech_types : 3 * max_speech_types]
|
423 |
+
remove_silence = args[3 * max_speech_types]
|
424 |
+
# Collect the speech types and their audios into a dict
|
425 |
+
speech_types = OrderedDict()
|
426 |
+
|
427 |
+
ref_text_idx = 0
|
428 |
+
for name_input, audio_input, ref_text_input in zip(
|
429 |
+
speech_type_names_list, speech_type_audios_list, speech_type_ref_texts_list
|
430 |
+
):
|
431 |
+
if name_input and audio_input:
|
432 |
+
speech_types[name_input] = {"audio": audio_input, "ref_text": ref_text_input}
|
433 |
+
else:
|
434 |
+
speech_types[f"@{ref_text_idx}@"] = {"audio": "", "ref_text": ""}
|
435 |
+
ref_text_idx += 1
|
436 |
+
|
437 |
+
# Parse the gen_text into segments
|
438 |
+
segments = parse_speechtypes_text(gen_text)
|
439 |
+
|
440 |
+
# For each segment, generate speech
|
441 |
+
generated_audio_segments = []
|
442 |
+
current_style = "Regular"
|
443 |
+
|
444 |
+
for segment in segments:
|
445 |
+
style = segment["style"]
|
446 |
+
text = segment["text"]
|
447 |
+
|
448 |
+
if style in speech_types:
|
449 |
+
current_style = style
|
450 |
+
else:
|
451 |
+
# If style not available, default to Regular
|
452 |
+
current_style = "Regular"
|
453 |
+
|
454 |
+
ref_audio = speech_types[current_style]["audio"]
|
455 |
+
ref_text = speech_types[current_style].get("ref_text", "")
|
456 |
+
|
457 |
+
# Generate speech for this segment
|
458 |
+
audio_out, _, ref_text_out = infer(
|
459 |
+
ref_audio, ref_text, text, tts_model_choice, remove_silence, 0, show_info=print
|
460 |
+
) # show_info=print no pull to top when generating
|
461 |
+
sr, audio_data = audio_out
|
462 |
+
|
463 |
+
generated_audio_segments.append(audio_data)
|
464 |
+
speech_types[current_style]["ref_text"] = ref_text_out
|
465 |
+
|
466 |
+
# Concatenate all audio segments
|
467 |
+
if generated_audio_segments:
|
468 |
+
final_audio_data = np.concatenate(generated_audio_segments)
|
469 |
+
return [(sr, final_audio_data)] + [
|
470 |
+
gr.update(value=speech_types[style]["ref_text"]) for style in speech_types
|
471 |
+
]
|
472 |
+
else:
|
473 |
+
gr.Warning("No audio generated.")
|
474 |
+
return [None] + [gr.update(value=speech_types[style]["ref_text"]) for style in speech_types]
|
475 |
+
|
476 |
+
generate_multistyle_btn.click(
|
477 |
+
generate_multistyle_speech,
|
478 |
+
inputs=[
|
479 |
+
gen_text_input_multistyle,
|
480 |
+
]
|
481 |
+
+ speech_type_names
|
482 |
+
+ speech_type_audios
|
483 |
+
+ speech_type_ref_texts
|
484 |
+
+ [
|
485 |
+
remove_silence_multistyle,
|
486 |
+
],
|
487 |
+
outputs=[audio_output_multistyle] + speech_type_ref_texts,
|
488 |
+
)
|
489 |
+
|
490 |
+
# Validation function to disable Generate button if speech types are missing
|
491 |
+
def validate_speech_types(gen_text, regular_name, *args):
|
492 |
+
speech_type_names_list = args[:max_speech_types]
|
493 |
+
|
494 |
+
# Collect the speech types names
|
495 |
+
speech_types_available = set()
|
496 |
+
if regular_name:
|
497 |
+
speech_types_available.add(regular_name)
|
498 |
+
for name_input in speech_type_names_list:
|
499 |
+
if name_input:
|
500 |
+
speech_types_available.add(name_input)
|
501 |
+
|
502 |
+
# Parse the gen_text to get the speech types used
|
503 |
+
segments = parse_speechtypes_text(gen_text)
|
504 |
+
speech_types_in_text = set(segment["style"] for segment in segments)
|
505 |
+
|
506 |
+
# Check if all speech types in text are available
|
507 |
+
missing_speech_types = speech_types_in_text - speech_types_available
|
508 |
+
|
509 |
+
if missing_speech_types:
|
510 |
+
# Disable the generate button
|
511 |
+
return gr.update(interactive=False)
|
512 |
+
else:
|
513 |
+
# Enable the generate button
|
514 |
+
return gr.update(interactive=True)
|
515 |
+
|
516 |
+
gen_text_input_multistyle.change(
|
517 |
+
validate_speech_types,
|
518 |
+
inputs=[gen_text_input_multistyle, regular_name] + speech_type_names,
|
519 |
+
outputs=generate_multistyle_btn,
|
520 |
+
)
|
521 |
+
|
522 |
+
|
523 |
+
with gr.Blocks() as app_chat:
|
524 |
+
gr.Markdown(
|
525 |
+
"""
|
526 |
+
# Voice Chat
|
527 |
+
Have a conversation with an AI using your reference voice!
|
528 |
+
1. Upload a reference audio clip and optionally its transcript.
|
529 |
+
2. Load the chat model.
|
530 |
+
3. Record your message through your microphone.
|
531 |
+
4. The AI will respond using the reference voice.
|
532 |
+
"""
|
533 |
+
)
|
534 |
+
|
535 |
+
if not USING_SPACES:
|
536 |
+
load_chat_model_btn = gr.Button("Load Chat Model", variant="primary")
|
537 |
+
|
538 |
+
chat_interface_container = gr.Column(visible=False)
|
539 |
+
|
540 |
+
@gpu_decorator
|
541 |
+
def load_chat_model():
|
542 |
+
global chat_model_state, chat_tokenizer_state
|
543 |
+
if chat_model_state is None:
|
544 |
+
show_info = gr.Info
|
545 |
+
show_info("Loading chat model...")
|
546 |
+
model_name = "Qwen/Qwen2.5-3B-Instruct"
|
547 |
+
chat_model_state = AutoModelForCausalLM.from_pretrained(
|
548 |
+
model_name, torch_dtype="auto", device_map="auto"
|
549 |
+
)
|
550 |
+
chat_tokenizer_state = AutoTokenizer.from_pretrained(model_name)
|
551 |
+
show_info("Chat model loaded.")
|
552 |
+
|
553 |
+
return gr.update(visible=False), gr.update(visible=True)
|
554 |
+
|
555 |
+
load_chat_model_btn.click(load_chat_model, outputs=[load_chat_model_btn, chat_interface_container])
|
556 |
+
|
557 |
+
else:
|
558 |
+
chat_interface_container = gr.Column()
|
559 |
+
|
560 |
+
if chat_model_state is None:
|
561 |
+
model_name = "Qwen/Qwen2.5-3B-Instruct"
|
562 |
+
chat_model_state = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
|
563 |
+
chat_tokenizer_state = AutoTokenizer.from_pretrained(model_name)
|
564 |
+
|
565 |
+
with chat_interface_container:
|
566 |
+
with gr.Row():
|
567 |
+
with gr.Column():
|
568 |
+
ref_audio_chat = gr.Audio(label="Reference Audio", type="filepath")
|
569 |
+
with gr.Column():
|
570 |
+
with gr.Accordion("Advanced Settings", open=False):
|
571 |
+
remove_silence_chat = gr.Checkbox(
|
572 |
+
label="Remove Silences",
|
573 |
+
value=True,
|
574 |
+
)
|
575 |
+
ref_text_chat = gr.Textbox(
|
576 |
+
label="Reference Text",
|
577 |
+
info="Optional: Leave blank to auto-transcribe",
|
578 |
+
lines=2,
|
579 |
+
)
|
580 |
+
system_prompt_chat = gr.Textbox(
|
581 |
+
label="System Prompt",
|
582 |
+
value="You are not an AI assistant, you are whoever the user says you are. You must stay in character. Keep your responses concise since they will be spoken out loud.",
|
583 |
+
lines=2,
|
584 |
+
)
|
585 |
+
|
586 |
+
chatbot_interface = gr.Chatbot(label="Conversation")
|
587 |
+
|
588 |
+
with gr.Row():
|
589 |
+
with gr.Column():
|
590 |
+
audio_input_chat = gr.Microphone(
|
591 |
+
label="Speak your message",
|
592 |
+
type="filepath",
|
593 |
+
)
|
594 |
+
audio_output_chat = gr.Audio(autoplay=True)
|
595 |
+
with gr.Column():
|
596 |
+
text_input_chat = gr.Textbox(
|
597 |
+
label="Type your message",
|
598 |
+
lines=1,
|
599 |
+
)
|
600 |
+
send_btn_chat = gr.Button("Send Message")
|
601 |
+
clear_btn_chat = gr.Button("Clear Conversation")
|
602 |
+
|
603 |
+
conversation_state = gr.State(
|
604 |
+
value=[
|
605 |
+
{
|
606 |
+
"role": "system",
|
607 |
+
"content": "You are not an AI assistant, you are whoever the user says you are. You must stay in character. Keep your responses concise since they will be spoken out loud.",
|
608 |
+
}
|
609 |
+
]
|
610 |
+
)
|
611 |
+
|
612 |
+
# Modify process_audio_input to use model and tokenizer from state
|
613 |
+
@gpu_decorator
|
614 |
+
def process_audio_input(audio_path, text, history, conv_state):
|
615 |
+
"""Handle audio or text input from user"""
|
616 |
+
|
617 |
+
if not audio_path and not text.strip():
|
618 |
+
return history, conv_state, ""
|
619 |
+
|
620 |
+
if audio_path:
|
621 |
+
text = preprocess_ref_audio_text(audio_path, text)[1]
|
622 |
+
|
623 |
+
if not text.strip():
|
624 |
+
return history, conv_state, ""
|
625 |
+
|
626 |
+
conv_state.append({"role": "user", "content": text})
|
627 |
+
history.append((text, None))
|
628 |
+
|
629 |
+
response = generate_response(conv_state, chat_model_state, chat_tokenizer_state)
|
630 |
+
|
631 |
+
conv_state.append({"role": "assistant", "content": response})
|
632 |
+
history[-1] = (text, response)
|
633 |
+
|
634 |
+
return history, conv_state, ""
|
635 |
+
|
636 |
+
@gpu_decorator
|
637 |
+
def generate_audio_response(history, ref_audio, ref_text, remove_silence):
|
638 |
+
"""Generate TTS audio for AI response"""
|
639 |
+
if not history or not ref_audio:
|
640 |
+
return None
|
641 |
+
|
642 |
+
last_user_message, last_ai_response = history[-1]
|
643 |
+
if not last_ai_response:
|
644 |
+
return None
|
645 |
+
|
646 |
+
audio_result, _, ref_text_out = infer(
|
647 |
+
ref_audio,
|
648 |
+
ref_text,
|
649 |
+
last_ai_response,
|
650 |
+
tts_model_choice,
|
651 |
+
remove_silence,
|
652 |
+
cross_fade_duration=0.15,
|
653 |
+
speed=1.0,
|
654 |
+
show_info=print, # show_info=print no pull to top when generating
|
655 |
+
)
|
656 |
+
return audio_result, gr.update(value=ref_text_out)
|
657 |
+
|
658 |
+
def clear_conversation():
|
659 |
+
"""Reset the conversation"""
|
660 |
+
return [], [
|
661 |
+
{
|
662 |
+
"role": "system",
|
663 |
+
"content": "You are not an AI assistant, you are whoever the user says you are. You must stay in character. Keep your responses concise since they will be spoken out loud.",
|
664 |
+
}
|
665 |
+
]
|
666 |
+
|
667 |
+
def update_system_prompt(new_prompt):
|
668 |
+
"""Update the system prompt and reset the conversation"""
|
669 |
+
new_conv_state = [{"role": "system", "content": new_prompt}]
|
670 |
+
return [], new_conv_state
|
671 |
+
|
672 |
+
# Handle audio input
|
673 |
+
audio_input_chat.stop_recording(
|
674 |
+
process_audio_input,
|
675 |
+
inputs=[audio_input_chat, text_input_chat, chatbot_interface, conversation_state],
|
676 |
+
outputs=[chatbot_interface, conversation_state],
|
677 |
+
).then(
|
678 |
+
generate_audio_response,
|
679 |
+
inputs=[chatbot_interface, ref_audio_chat, ref_text_chat, remove_silence_chat],
|
680 |
+
outputs=[audio_output_chat, ref_text_chat],
|
681 |
+
).then(
|
682 |
+
lambda: None,
|
683 |
+
None,
|
684 |
+
audio_input_chat,
|
685 |
+
)
|
686 |
+
|
687 |
+
# Handle text input
|
688 |
+
text_input_chat.submit(
|
689 |
+
process_audio_input,
|
690 |
+
inputs=[audio_input_chat, text_input_chat, chatbot_interface, conversation_state],
|
691 |
+
outputs=[chatbot_interface, conversation_state],
|
692 |
+
).then(
|
693 |
+
generate_audio_response,
|
694 |
+
inputs=[chatbot_interface, ref_audio_chat, ref_text_chat, remove_silence_chat],
|
695 |
+
outputs=[audio_output_chat, ref_text_chat],
|
696 |
+
).then(
|
697 |
+
lambda: None,
|
698 |
+
None,
|
699 |
+
text_input_chat,
|
700 |
+
)
|
701 |
+
|
702 |
+
# Handle send button
|
703 |
+
send_btn_chat.click(
|
704 |
+
process_audio_input,
|
705 |
+
inputs=[audio_input_chat, text_input_chat, chatbot_interface, conversation_state],
|
706 |
+
outputs=[chatbot_interface, conversation_state],
|
707 |
+
).then(
|
708 |
+
generate_audio_response,
|
709 |
+
inputs=[chatbot_interface, ref_audio_chat, ref_text_chat, remove_silence_chat],
|
710 |
+
outputs=[audio_output_chat, ref_text_chat],
|
711 |
+
).then(
|
712 |
+
lambda: None,
|
713 |
+
None,
|
714 |
+
text_input_chat,
|
715 |
+
)
|
716 |
+
|
717 |
+
# Handle clear button
|
718 |
+
clear_btn_chat.click(
|
719 |
+
clear_conversation,
|
720 |
+
outputs=[chatbot_interface, conversation_state],
|
721 |
+
)
|
722 |
+
|
723 |
+
# Handle system prompt change and reset conversation
|
724 |
+
system_prompt_chat.change(
|
725 |
+
update_system_prompt,
|
726 |
+
inputs=system_prompt_chat,
|
727 |
+
outputs=[chatbot_interface, conversation_state],
|
728 |
+
)
|
729 |
+
|
730 |
+
|
731 |
+
with gr.Blocks() as app:
|
732 |
+
gr.Markdown(
|
733 |
+
"""
|
734 |
+
# E2/F5 TTS
|
735 |
+
|
736 |
+
This is a local web UI for F5 TTS with advanced batch processing support. This app supports the following TTS models:
|
737 |
+
|
738 |
+
* [F5-TTS](https://arxiv.org/abs/2410.06885) (A Fairytaler that Fakes Fluent and Faithful Speech with Flow Matching)
|
739 |
+
* [E2 TTS](https://arxiv.org/abs/2406.18009) (Embarrassingly Easy Fully Non-Autoregressive Zero-Shot TTS)
|
740 |
+
|
741 |
+
The checkpoints currently support English and Chinese.
|
742 |
+
|
743 |
+
If you're having issues, try converting your reference audio to WAV or MP3, clipping it to 15s with ✂ in the bottom right corner (otherwise might have non-optimal auto-trimmed result).
|
744 |
+
|
745 |
+
**NOTE: Reference text will be automatically transcribed with Whisper if not provided. For best results, keep your reference clips short (<15s). Ensure the audio is fully uploaded before generating.**
|
746 |
+
"""
|
747 |
+
)
|
748 |
+
|
749 |
+
last_used_custom = files("f5_tts").joinpath("infer/.cache/last_used_custom.txt")
|
750 |
+
|
751 |
+
def load_last_used_custom():
|
752 |
+
try:
|
753 |
+
with open(last_used_custom, "r") as f:
|
754 |
+
return f.read().split(",")
|
755 |
+
except FileNotFoundError:
|
756 |
+
last_used_custom.parent.mkdir(parents=True, exist_ok=True)
|
757 |
+
return [
|
758 |
+
"hf://SWivid/F5-TTS/F5TTS_Base/model_1200000.safetensors",
|
759 |
+
"hf://SWivid/F5-TTS/F5TTS_Base/vocab.txt",
|
760 |
+
]
|
761 |
+
|
762 |
+
def switch_tts_model(new_choice):
|
763 |
+
global tts_model_choice
|
764 |
+
if new_choice == "Custom": # override in case webpage is refreshed
|
765 |
+
custom_ckpt_path, custom_vocab_path = load_last_used_custom()
|
766 |
+
tts_model_choice = ["Custom", custom_ckpt_path, custom_vocab_path]
|
767 |
+
return gr.update(visible=True, value=custom_ckpt_path), gr.update(visible=True, value=custom_vocab_path)
|
768 |
+
else:
|
769 |
+
tts_model_choice = new_choice
|
770 |
+
return gr.update(visible=False), gr.update(visible=False)
|
771 |
+
|
772 |
+
def set_custom_model(custom_ckpt_path, custom_vocab_path):
|
773 |
+
global tts_model_choice
|
774 |
+
tts_model_choice = ["Custom", custom_ckpt_path, custom_vocab_path]
|
775 |
+
with open(last_used_custom, "w") as f:
|
776 |
+
f.write(f"{custom_ckpt_path},{custom_vocab_path}")
|
777 |
+
|
778 |
+
with gr.Row():
|
779 |
+
if not USING_SPACES:
|
780 |
+
choose_tts_model = gr.Radio(
|
781 |
+
choices=[DEFAULT_TTS_MODEL, "E2-TTS", "Custom"], label="Choose TTS Model", value=DEFAULT_TTS_MODEL
|
782 |
+
)
|
783 |
+
else:
|
784 |
+
choose_tts_model = gr.Radio(
|
785 |
+
choices=[DEFAULT_TTS_MODEL, "E2-TTS"], label="Choose TTS Model", value=DEFAULT_TTS_MODEL
|
786 |
+
)
|
787 |
+
custom_ckpt_path = gr.Dropdown(
|
788 |
+
choices=["hf://SWivid/F5-TTS/F5TTS_Base/model_1200000.safetensors"],
|
789 |
+
value=load_last_used_custom()[0],
|
790 |
+
allow_custom_value=True,
|
791 |
+
label="MODEL CKPT: local_path | hf://user_id/repo_id/model_ckpt",
|
792 |
+
visible=False,
|
793 |
+
)
|
794 |
+
custom_vocab_path = gr.Dropdown(
|
795 |
+
choices=["hf://SWivid/F5-TTS/F5TTS_Base/vocab.txt"],
|
796 |
+
value=load_last_used_custom()[1],
|
797 |
+
allow_custom_value=True,
|
798 |
+
label="VOCAB FILE: local_path | hf://user_id/repo_id/vocab_file",
|
799 |
+
visible=False,
|
800 |
+
)
|
801 |
+
|
802 |
+
choose_tts_model.change(
|
803 |
+
switch_tts_model,
|
804 |
+
inputs=[choose_tts_model],
|
805 |
+
outputs=[custom_ckpt_path, custom_vocab_path],
|
806 |
+
show_progress="hidden",
|
807 |
+
)
|
808 |
+
custom_ckpt_path.change(
|
809 |
+
set_custom_model,
|
810 |
+
inputs=[custom_ckpt_path, custom_vocab_path],
|
811 |
+
show_progress="hidden",
|
812 |
+
)
|
813 |
+
custom_vocab_path.change(
|
814 |
+
set_custom_model,
|
815 |
+
inputs=[custom_ckpt_path, custom_vocab_path],
|
816 |
+
show_progress="hidden",
|
817 |
+
)
|
818 |
+
|
819 |
+
gr.TabbedInterface(
|
820 |
+
[app_tts, app_multistyle, app_chat, app_credits],
|
821 |
+
["Basic-TTS", "Multi-Speech", "Voice-Chat", "Credits"],
|
822 |
+
)
|
823 |
+
|
824 |
+
|
825 |
+
@click.command()
|
826 |
+
@click.option("--port", "-p", default=None, type=int, help="Port to run the app on")
|
827 |
+
@click.option("--host", "-H", default=None, help="Host to run the app on")
|
828 |
+
@click.option(
|
829 |
+
"--share",
|
830 |
+
"-s",
|
831 |
+
default=False,
|
832 |
+
is_flag=True,
|
833 |
+
help="Share the app via Gradio share link",
|
834 |
+
)
|
835 |
+
@click.option("--api", "-a", default=True, is_flag=True, help="Allow API access")
|
836 |
+
@click.option(
|
837 |
+
"--root_path",
|
838 |
+
"-r",
|
839 |
+
default=None,
|
840 |
+
type=str,
|
841 |
+
help='The root path (or "mount point") of the application, if it\'s not served from the root ("/") of the domain. Often used when the application is behind a reverse proxy that forwards requests to the application, e.g. set "/myapp" or full URL for application served at "https://example.com/myapp".',
|
842 |
+
)
|
843 |
+
def main(port, host, share, api, root_path):
|
844 |
+
global app
|
845 |
+
print("Starting app...")
|
846 |
+
app.queue(api_open=api).launch(server_name=host, server_port=port, share=share, show_api=api, root_path=root_path)
|
847 |
+
|
848 |
+
|
849 |
+
if __name__ == "__main__":
|
850 |
+
if not USING_SPACES:
|
851 |
+
main()
|
852 |
+
else:
|
853 |
+
app.queue().launch()
|
f5_tts/infer/speech_edit.py
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
os.environ["PYTOCH_ENABLE_MPS_FALLBACK"] = "1" # for MPS device compatibility
|
4 |
+
|
5 |
+
import torch
|
6 |
+
import torch.nn.functional as F
|
7 |
+
import torchaudio
|
8 |
+
|
9 |
+
from f5_tts.infer.utils_infer import load_checkpoint, load_vocoder, save_spectrogram
|
10 |
+
from f5_tts.model import CFM, DiT, UNetT
|
11 |
+
from f5_tts.model.utils import convert_char_to_pinyin, get_tokenizer
|
12 |
+
|
13 |
+
device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
|
14 |
+
|
15 |
+
|
16 |
+
# --------------------- Dataset Settings -------------------- #
|
17 |
+
|
18 |
+
target_sample_rate = 24000
|
19 |
+
n_mel_channels = 100
|
20 |
+
hop_length = 256
|
21 |
+
win_length = 1024
|
22 |
+
n_fft = 1024
|
23 |
+
mel_spec_type = "vocos" # 'vocos' or 'bigvgan'
|
24 |
+
target_rms = 0.1
|
25 |
+
|
26 |
+
tokenizer = "pinyin"
|
27 |
+
dataset_name = "Emilia_ZH_EN"
|
28 |
+
|
29 |
+
|
30 |
+
# ---------------------- infer setting ---------------------- #
|
31 |
+
|
32 |
+
seed = None # int | None
|
33 |
+
|
34 |
+
exp_name = "F5TTS_Base" # F5TTS_Base | E2TTS_Base
|
35 |
+
ckpt_step = 1200000
|
36 |
+
|
37 |
+
nfe_step = 32 # 16, 32
|
38 |
+
cfg_strength = 2.0
|
39 |
+
ode_method = "euler" # euler | midpoint
|
40 |
+
sway_sampling_coef = -1.0
|
41 |
+
speed = 1.0
|
42 |
+
|
43 |
+
if exp_name == "F5TTS_Base":
|
44 |
+
model_cls = DiT
|
45 |
+
model_cfg = dict(dim=1024, depth=22, heads=16, ff_mult=2, text_dim=512, conv_layers=4)
|
46 |
+
|
47 |
+
elif exp_name == "E2TTS_Base":
|
48 |
+
model_cls = UNetT
|
49 |
+
model_cfg = dict(dim=1024, depth=24, heads=16, ff_mult=4)
|
50 |
+
|
51 |
+
ckpt_path = f"ckpts/{exp_name}/model_{ckpt_step}.safetensors"
|
52 |
+
output_dir = "tests"
|
53 |
+
|
54 |
+
# [leverage https://github.com/MahmoudAshraf97/ctc-forced-aligner to get char level alignment]
|
55 |
+
# pip install git+https://github.com/MahmoudAshraf97/ctc-forced-aligner.git
|
56 |
+
# [write the origin_text into a file, e.g. tests/test_edit.txt]
|
57 |
+
# ctc-forced-aligner --audio_path "src/f5_tts/infer/examples/basic/basic_ref_en.wav" --text_path "tests/test_edit.txt" --language "zho" --romanize --split_size "char"
|
58 |
+
# [result will be saved at same path of audio file]
|
59 |
+
# [--language "zho" for Chinese, "eng" for English]
|
60 |
+
# [if local ckpt, set --alignment_model "../checkpoints/mms-300m-1130-forced-aligner"]
|
61 |
+
|
62 |
+
audio_to_edit = "src/f5_tts/infer/examples/basic/basic_ref_en.wav"
|
63 |
+
origin_text = "Some call me nature, others call me mother nature."
|
64 |
+
target_text = "Some call me optimist, others call me realist."
|
65 |
+
parts_to_edit = [
|
66 |
+
[1.42, 2.44],
|
67 |
+
[4.04, 4.9],
|
68 |
+
] # stard_ends of "nature" & "mother nature", in seconds
|
69 |
+
fix_duration = [
|
70 |
+
1.2,
|
71 |
+
1,
|
72 |
+
] # fix duration for "optimist" & "realist", in seconds
|
73 |
+
|
74 |
+
# audio_to_edit = "src/f5_tts/infer/examples/basic/basic_ref_zh.wav"
|
75 |
+
# origin_text = "对,这就是我,万人敬仰的太乙真人。"
|
76 |
+
# target_text = "对,那就是你,万人敬仰的太白金星。"
|
77 |
+
# parts_to_edit = [[0.84, 1.4], [1.92, 2.4], [4.26, 6.26], ]
|
78 |
+
# fix_duration = None # use origin text duration
|
79 |
+
|
80 |
+
|
81 |
+
# -------------------------------------------------#
|
82 |
+
|
83 |
+
use_ema = True
|
84 |
+
|
85 |
+
if not os.path.exists(output_dir):
|
86 |
+
os.makedirs(output_dir)
|
87 |
+
|
88 |
+
# Vocoder model
|
89 |
+
local = False
|
90 |
+
if mel_spec_type == "vocos":
|
91 |
+
vocoder_local_path = "../checkpoints/charactr/vocos-mel-24khz"
|
92 |
+
elif mel_spec_type == "bigvgan":
|
93 |
+
vocoder_local_path = "../checkpoints/bigvgan_v2_24khz_100band_256x"
|
94 |
+
vocoder = load_vocoder(vocoder_name=mel_spec_type, is_local=local, local_path=vocoder_local_path)
|
95 |
+
|
96 |
+
# Tokenizer
|
97 |
+
vocab_char_map, vocab_size = get_tokenizer(dataset_name, tokenizer)
|
98 |
+
|
99 |
+
# Model
|
100 |
+
model = CFM(
|
101 |
+
transformer=model_cls(**model_cfg, text_num_embeds=vocab_size, mel_dim=n_mel_channels),
|
102 |
+
mel_spec_kwargs=dict(
|
103 |
+
n_fft=n_fft,
|
104 |
+
hop_length=hop_length,
|
105 |
+
win_length=win_length,
|
106 |
+
n_mel_channels=n_mel_channels,
|
107 |
+
target_sample_rate=target_sample_rate,
|
108 |
+
mel_spec_type=mel_spec_type,
|
109 |
+
),
|
110 |
+
odeint_kwargs=dict(
|
111 |
+
method=ode_method,
|
112 |
+
),
|
113 |
+
vocab_char_map=vocab_char_map,
|
114 |
+
).to(device)
|
115 |
+
|
116 |
+
dtype = torch.float32 if mel_spec_type == "bigvgan" else None
|
117 |
+
model = load_checkpoint(model, ckpt_path, device, dtype=dtype, use_ema=use_ema)
|
118 |
+
|
119 |
+
# Audio
|
120 |
+
audio, sr = torchaudio.load(audio_to_edit)
|
121 |
+
if audio.shape[0] > 1:
|
122 |
+
audio = torch.mean(audio, dim=0, keepdim=True)
|
123 |
+
rms = torch.sqrt(torch.mean(torch.square(audio)))
|
124 |
+
if rms < target_rms:
|
125 |
+
audio = audio * target_rms / rms
|
126 |
+
if sr != target_sample_rate:
|
127 |
+
resampler = torchaudio.transforms.Resample(sr, target_sample_rate)
|
128 |
+
audio = resampler(audio)
|
129 |
+
offset = 0
|
130 |
+
audio_ = torch.zeros(1, 0)
|
131 |
+
edit_mask = torch.zeros(1, 0, dtype=torch.bool)
|
132 |
+
for part in parts_to_edit:
|
133 |
+
start, end = part
|
134 |
+
part_dur = end - start if fix_duration is None else fix_duration.pop(0)
|
135 |
+
part_dur = part_dur * target_sample_rate
|
136 |
+
start = start * target_sample_rate
|
137 |
+
audio_ = torch.cat((audio_, audio[:, round(offset) : round(start)], torch.zeros(1, round(part_dur))), dim=-1)
|
138 |
+
edit_mask = torch.cat(
|
139 |
+
(
|
140 |
+
edit_mask,
|
141 |
+
torch.ones(1, round((start - offset) / hop_length), dtype=torch.bool),
|
142 |
+
torch.zeros(1, round(part_dur / hop_length), dtype=torch.bool),
|
143 |
+
),
|
144 |
+
dim=-1,
|
145 |
+
)
|
146 |
+
offset = end * target_sample_rate
|
147 |
+
# audio = torch.cat((audio_, audio[:, round(offset):]), dim = -1)
|
148 |
+
edit_mask = F.pad(edit_mask, (0, audio.shape[-1] // hop_length - edit_mask.shape[-1] + 1), value=True)
|
149 |
+
audio = audio.to(device)
|
150 |
+
edit_mask = edit_mask.to(device)
|
151 |
+
|
152 |
+
# Text
|
153 |
+
text_list = [target_text]
|
154 |
+
if tokenizer == "pinyin":
|
155 |
+
final_text_list = convert_char_to_pinyin(text_list)
|
156 |
+
else:
|
157 |
+
final_text_list = [text_list]
|
158 |
+
print(f"text : {text_list}")
|
159 |
+
print(f"pinyin: {final_text_list}")
|
160 |
+
|
161 |
+
# Duration
|
162 |
+
ref_audio_len = 0
|
163 |
+
duration = audio.shape[-1] // hop_length
|
164 |
+
|
165 |
+
# Inference
|
166 |
+
with torch.inference_mode():
|
167 |
+
generated, trajectory = model.sample(
|
168 |
+
cond=audio,
|
169 |
+
text=final_text_list,
|
170 |
+
duration=duration,
|
171 |
+
steps=nfe_step,
|
172 |
+
cfg_strength=cfg_strength,
|
173 |
+
sway_sampling_coef=sway_sampling_coef,
|
174 |
+
seed=seed,
|
175 |
+
edit_mask=edit_mask,
|
176 |
+
)
|
177 |
+
print(f"Generated mel: {generated.shape}")
|
178 |
+
|
179 |
+
# Final result
|
180 |
+
generated = generated.to(torch.float32)
|
181 |
+
generated = generated[:, ref_audio_len:, :]
|
182 |
+
gen_mel_spec = generated.permute(0, 2, 1)
|
183 |
+
if mel_spec_type == "vocos":
|
184 |
+
generated_wave = vocoder.decode(gen_mel_spec).cpu()
|
185 |
+
elif mel_spec_type == "bigvgan":
|
186 |
+
generated_wave = vocoder(gen_mel_spec).squeeze(0).cpu()
|
187 |
+
|
188 |
+
if rms < target_rms:
|
189 |
+
generated_wave = generated_wave * rms / target_rms
|
190 |
+
|
191 |
+
save_spectrogram(gen_mel_spec[0].cpu().numpy(), f"{output_dir}/speech_edit_out.png")
|
192 |
+
torchaudio.save(f"{output_dir}/speech_edit_out.wav", generated_wave, target_sample_rate)
|
193 |
+
print(f"Generated wav: {generated_wave.shape}")
|
f5_tts/infer/utils_infer.py
ADDED
@@ -0,0 +1,552 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# A unified script for inference process
|
2 |
+
# Make adjustments inside functions, and consider both gradio and cli scripts if need to change func output format
|
3 |
+
import os
|
4 |
+
import sys
|
5 |
+
|
6 |
+
os.environ["PYTOCH_ENABLE_MPS_FALLBACK"] = "1" # for MPS device compatibility
|
7 |
+
sys.path.append(f"../../{os.path.dirname(os.path.abspath(__file__))}/third_party/BigVGAN/")
|
8 |
+
|
9 |
+
import hashlib
|
10 |
+
import re
|
11 |
+
import tempfile
|
12 |
+
from importlib.resources import files
|
13 |
+
|
14 |
+
import matplotlib
|
15 |
+
|
16 |
+
matplotlib.use("Agg")
|
17 |
+
|
18 |
+
import matplotlib.pylab as plt
|
19 |
+
import numpy as np
|
20 |
+
import torch
|
21 |
+
import torchaudio
|
22 |
+
import tqdm
|
23 |
+
from huggingface_hub import snapshot_download, hf_hub_download
|
24 |
+
from pydub import AudioSegment, silence
|
25 |
+
from transformers import pipeline
|
26 |
+
from vocos import Vocos
|
27 |
+
|
28 |
+
from f5_tts.model import CFM
|
29 |
+
from f5_tts.model.utils import (
|
30 |
+
get_tokenizer,
|
31 |
+
convert_char_to_pinyin,
|
32 |
+
)
|
33 |
+
|
34 |
+
_ref_audio_cache = {}
|
35 |
+
|
36 |
+
device = "cuda" if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu"
|
37 |
+
|
38 |
+
# -----------------------------------------
|
39 |
+
|
40 |
+
target_sample_rate = 24000
|
41 |
+
n_mel_channels = 100
|
42 |
+
hop_length = 256
|
43 |
+
win_length = 1024
|
44 |
+
n_fft = 1024
|
45 |
+
mel_spec_type = "vocos"
|
46 |
+
target_rms = 0.1
|
47 |
+
cross_fade_duration = 0.15
|
48 |
+
ode_method = "euler"
|
49 |
+
nfe_step = 32 # 16, 32
|
50 |
+
cfg_strength = 2.0
|
51 |
+
sway_sampling_coef = -1.0
|
52 |
+
speed = 1.0
|
53 |
+
fix_duration = None
|
54 |
+
|
55 |
+
# -----------------------------------------
|
56 |
+
|
57 |
+
|
58 |
+
# chunk text into smaller pieces
|
59 |
+
|
60 |
+
|
61 |
+
def chunk_text(text, max_chars=135):
|
62 |
+
"""
|
63 |
+
Splits the input text into chunks, each with a maximum number of characters.
|
64 |
+
|
65 |
+
Args:
|
66 |
+
text (str): The text to be split.
|
67 |
+
max_chars (int): The maximum number of characters per chunk.
|
68 |
+
|
69 |
+
Returns:
|
70 |
+
List[str]: A list of text chunks.
|
71 |
+
"""
|
72 |
+
chunks = []
|
73 |
+
current_chunk = ""
|
74 |
+
# Split the text into sentences based on punctuation followed by whitespace
|
75 |
+
sentences = re.split(r"(?<=[;:,.!?])\s+|(?<=[;:,。!?])", text)
|
76 |
+
|
77 |
+
for sentence in sentences:
|
78 |
+
if len(current_chunk.encode("utf-8")) + len(sentence.encode("utf-8")) <= max_chars:
|
79 |
+
current_chunk += sentence + " " if sentence and len(sentence[-1].encode("utf-8")) == 1 else sentence
|
80 |
+
else:
|
81 |
+
if current_chunk:
|
82 |
+
chunks.append(current_chunk.strip())
|
83 |
+
current_chunk = sentence + " " if sentence and len(sentence[-1].encode("utf-8")) == 1 else sentence
|
84 |
+
|
85 |
+
if current_chunk:
|
86 |
+
chunks.append(current_chunk.strip())
|
87 |
+
|
88 |
+
return chunks
|
89 |
+
|
90 |
+
|
91 |
+
# load vocoder
|
92 |
+
def load_vocoder(vocoder_name="vocos", is_local=False, local_path="", device=device, hf_cache_dir=None):
|
93 |
+
if vocoder_name == "vocos":
|
94 |
+
# vocoder = Vocos.from_pretrained("charactr/vocos-mel-24khz").to(device)
|
95 |
+
if is_local:
|
96 |
+
print(f"Load vocos from local path {local_path}")
|
97 |
+
config_path = f"{local_path}/config.yaml"
|
98 |
+
model_path = f"{local_path}/pytorch_model.bin"
|
99 |
+
else:
|
100 |
+
print("Download Vocos from huggingface charactr/vocos-mel-24khz")
|
101 |
+
repo_id = "charactr/vocos-mel-24khz"
|
102 |
+
config_path = hf_hub_download(repo_id=repo_id, cache_dir=hf_cache_dir, filename="config.yaml")
|
103 |
+
model_path = hf_hub_download(repo_id=repo_id, cache_dir=hf_cache_dir, filename="pytorch_model.bin")
|
104 |
+
vocoder = Vocos.from_hparams(config_path)
|
105 |
+
state_dict = torch.load(model_path, map_location="cpu", weights_only=True)
|
106 |
+
from vocos.feature_extractors import EncodecFeatures
|
107 |
+
|
108 |
+
if isinstance(vocoder.feature_extractor, EncodecFeatures):
|
109 |
+
encodec_parameters = {
|
110 |
+
"feature_extractor.encodec." + key: value
|
111 |
+
for key, value in vocoder.feature_extractor.encodec.state_dict().items()
|
112 |
+
}
|
113 |
+
state_dict.update(encodec_parameters)
|
114 |
+
vocoder.load_state_dict(state_dict)
|
115 |
+
vocoder = vocoder.eval().to(device)
|
116 |
+
elif vocoder_name == "bigvgan":
|
117 |
+
try:
|
118 |
+
from third_party.BigVGAN import bigvgan
|
119 |
+
except ImportError:
|
120 |
+
print("You need to follow the README to init submodule and change the BigVGAN source code.")
|
121 |
+
if is_local:
|
122 |
+
"""download from https://huggingface.co/nvidia/bigvgan_v2_24khz_100band_256x/tree/main"""
|
123 |
+
vocoder = bigvgan.BigVGAN.from_pretrained(local_path, use_cuda_kernel=False)
|
124 |
+
else:
|
125 |
+
local_path = snapshot_download(repo_id="nvidia/bigvgan_v2_24khz_100band_256x", cache_dir=hf_cache_dir)
|
126 |
+
vocoder = bigvgan.BigVGAN.from_pretrained(local_path, use_cuda_kernel=False)
|
127 |
+
|
128 |
+
vocoder.remove_weight_norm()
|
129 |
+
vocoder = vocoder.eval().to(device)
|
130 |
+
return vocoder
|
131 |
+
|
132 |
+
|
133 |
+
# load asr pipeline
|
134 |
+
|
135 |
+
asr_pipe = None
|
136 |
+
|
137 |
+
|
138 |
+
def initialize_asr_pipeline(device: str = device, dtype=None):
|
139 |
+
if dtype is None:
|
140 |
+
dtype = (
|
141 |
+
torch.float16
|
142 |
+
if "cuda" in device
|
143 |
+
and torch.cuda.get_device_properties(device).major >= 6
|
144 |
+
and not torch.cuda.get_device_name().endswith("[ZLUDA]")
|
145 |
+
else torch.float32
|
146 |
+
)
|
147 |
+
global asr_pipe
|
148 |
+
asr_pipe = pipeline(
|
149 |
+
"automatic-speech-recognition",
|
150 |
+
model="openai/whisper-large-v3-turbo",
|
151 |
+
torch_dtype=dtype,
|
152 |
+
device=device,
|
153 |
+
)
|
154 |
+
|
155 |
+
|
156 |
+
# transcribe
|
157 |
+
|
158 |
+
|
159 |
+
def transcribe(ref_audio, language=None):
|
160 |
+
global asr_pipe
|
161 |
+
if asr_pipe is None:
|
162 |
+
initialize_asr_pipeline(device=device)
|
163 |
+
return asr_pipe(
|
164 |
+
ref_audio,
|
165 |
+
chunk_length_s=30,
|
166 |
+
batch_size=128,
|
167 |
+
generate_kwargs={"task": "transcribe", "language": language} if language else {"task": "transcribe"},
|
168 |
+
return_timestamps=False,
|
169 |
+
)["text"].strip()
|
170 |
+
|
171 |
+
|
172 |
+
# load model checkpoint for inference
|
173 |
+
|
174 |
+
|
175 |
+
def load_checkpoint(model, ckpt_path, device: str, dtype=None, use_ema=True):
|
176 |
+
if dtype is None:
|
177 |
+
dtype = torch.float32
|
178 |
+
# dtype = (
|
179 |
+
# torch.float16
|
180 |
+
# if "cuda" in device
|
181 |
+
# and torch.cuda.get_device_properties(device).major >= 6
|
182 |
+
# and not torch.cuda.get_device_name().endswith("[ZLUDA]")
|
183 |
+
# else torch.float32
|
184 |
+
# )
|
185 |
+
model = model.to(dtype)
|
186 |
+
|
187 |
+
ckpt_type = ckpt_path.split(".")[-1]
|
188 |
+
if ckpt_type == "safetensors":
|
189 |
+
from safetensors.torch import load_file
|
190 |
+
|
191 |
+
checkpoint = load_file(ckpt_path, device=device)
|
192 |
+
else:
|
193 |
+
checkpoint = torch.load(ckpt_path, map_location=device, weights_only=True)
|
194 |
+
|
195 |
+
if use_ema:
|
196 |
+
if ckpt_type == "safetensors":
|
197 |
+
checkpoint = {"ema_model_state_dict": checkpoint}
|
198 |
+
checkpoint["model_state_dict"] = {
|
199 |
+
k.replace("ema_model.", ""): v
|
200 |
+
for k, v in checkpoint["ema_model_state_dict"].items()
|
201 |
+
if k not in ["initted", "step"]
|
202 |
+
}
|
203 |
+
|
204 |
+
# patch for backward compatibility, 305e3ea
|
205 |
+
for key in ["mel_spec.mel_stft.mel_scale.fb", "mel_spec.mel_stft.spectrogram.window"]:
|
206 |
+
if key in checkpoint["model_state_dict"]:
|
207 |
+
del checkpoint["model_state_dict"][key]
|
208 |
+
|
209 |
+
model.load_state_dict(checkpoint["model_state_dict"])
|
210 |
+
else:
|
211 |
+
if ckpt_type == "safetensors":
|
212 |
+
checkpoint = {"model_state_dict": checkpoint}
|
213 |
+
model.load_state_dict(checkpoint["model_state_dict"])
|
214 |
+
|
215 |
+
del checkpoint
|
216 |
+
torch.cuda.empty_cache()
|
217 |
+
|
218 |
+
return model.to(device)
|
219 |
+
|
220 |
+
|
221 |
+
# load model for inference
|
222 |
+
|
223 |
+
|
224 |
+
def load_model(
|
225 |
+
model_cls,
|
226 |
+
model_cfg,
|
227 |
+
ckpt_path,
|
228 |
+
mel_spec_type=mel_spec_type,
|
229 |
+
vocab_file="",
|
230 |
+
ode_method=ode_method,
|
231 |
+
use_ema=True,
|
232 |
+
device=device,
|
233 |
+
):
|
234 |
+
if vocab_file == "":
|
235 |
+
vocab_file = str(files("f5_tts").joinpath("infer/examples/vocab.txt"))
|
236 |
+
tokenizer = "custom"
|
237 |
+
|
238 |
+
print("\nvocab : ", vocab_file)
|
239 |
+
print("token : ", tokenizer)
|
240 |
+
print("model : ", ckpt_path, "\n")
|
241 |
+
|
242 |
+
vocab_char_map, vocab_size = get_tokenizer(vocab_file, tokenizer)
|
243 |
+
model = CFM(
|
244 |
+
transformer=model_cls(**model_cfg, text_num_embeds=vocab_size, mel_dim=n_mel_channels),
|
245 |
+
mel_spec_kwargs=dict(
|
246 |
+
n_fft=n_fft,
|
247 |
+
hop_length=hop_length,
|
248 |
+
win_length=win_length,
|
249 |
+
n_mel_channels=n_mel_channels,
|
250 |
+
target_sample_rate=target_sample_rate,
|
251 |
+
mel_spec_type=mel_spec_type,
|
252 |
+
),
|
253 |
+
odeint_kwargs=dict(
|
254 |
+
method=ode_method,
|
255 |
+
),
|
256 |
+
vocab_char_map=vocab_char_map,
|
257 |
+
).to(device)
|
258 |
+
|
259 |
+
dtype = torch.float32 if mel_spec_type == "bigvgan" else None
|
260 |
+
model = load_checkpoint(model, ckpt_path, device, dtype=dtype, use_ema=use_ema)
|
261 |
+
|
262 |
+
return model
|
263 |
+
|
264 |
+
|
265 |
+
def remove_silence_edges(audio, silence_threshold=-42):
|
266 |
+
# Remove silence from the start
|
267 |
+
non_silent_start_idx = silence.detect_leading_silence(audio, silence_threshold=silence_threshold)
|
268 |
+
audio = audio[non_silent_start_idx:]
|
269 |
+
|
270 |
+
# Remove silence from the end
|
271 |
+
non_silent_end_duration = audio.duration_seconds
|
272 |
+
for ms in reversed(audio):
|
273 |
+
if ms.dBFS > silence_threshold:
|
274 |
+
break
|
275 |
+
non_silent_end_duration -= 0.001
|
276 |
+
trimmed_audio = audio[: int(non_silent_end_duration * 1000)]
|
277 |
+
|
278 |
+
return trimmed_audio
|
279 |
+
|
280 |
+
|
281 |
+
# preprocess reference audio and text
|
282 |
+
|
283 |
+
|
284 |
+
def preprocess_ref_audio_text(ref_audio_orig, ref_text, clip_short=True, show_info=print, device=device):
|
285 |
+
# show_info("Converting audio...")
|
286 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as f:
|
287 |
+
aseg = AudioSegment.from_file(ref_audio_orig)
|
288 |
+
|
289 |
+
if clip_short:
|
290 |
+
# 1. try to find long silence for clipping
|
291 |
+
non_silent_segs = silence.split_on_silence(
|
292 |
+
aseg, min_silence_len=1000, silence_thresh=-50, keep_silence=1000, seek_step=10
|
293 |
+
)
|
294 |
+
non_silent_wave = AudioSegment.silent(duration=0)
|
295 |
+
for non_silent_seg in non_silent_segs:
|
296 |
+
if len(non_silent_wave) > 6000 and len(non_silent_wave + non_silent_seg) > 15000:
|
297 |
+
show_info("Audio is over 15s, clipping short. (1)")
|
298 |
+
break
|
299 |
+
non_silent_wave += non_silent_seg
|
300 |
+
|
301 |
+
# 2. try to find short silence for clipping if 1. failed
|
302 |
+
if len(non_silent_wave) > 15000:
|
303 |
+
non_silent_segs = silence.split_on_silence(
|
304 |
+
aseg, min_silence_len=100, silence_thresh=-40, keep_silence=1000, seek_step=10
|
305 |
+
)
|
306 |
+
non_silent_wave = AudioSegment.silent(duration=0)
|
307 |
+
for non_silent_seg in non_silent_segs:
|
308 |
+
if len(non_silent_wave) > 6000 and len(non_silent_wave + non_silent_seg) > 15000:
|
309 |
+
show_info("Audio is over 15s, clipping short. (2)")
|
310 |
+
break
|
311 |
+
non_silent_wave += non_silent_seg
|
312 |
+
|
313 |
+
aseg = non_silent_wave
|
314 |
+
|
315 |
+
# 3. if no proper silence found for clipping
|
316 |
+
if len(aseg) > 15000:
|
317 |
+
aseg = aseg[:15000]
|
318 |
+
show_info("Audio is over 15s, clipping short. (3)")
|
319 |
+
|
320 |
+
aseg = remove_silence_edges(aseg) + AudioSegment.silent(duration=50)
|
321 |
+
aseg.export(f.name, format="wav")
|
322 |
+
ref_audio = f.name
|
323 |
+
|
324 |
+
# Compute a hash of the reference audio file
|
325 |
+
with open(ref_audio, "rb") as audio_file:
|
326 |
+
audio_data = audio_file.read()
|
327 |
+
audio_hash = hashlib.md5(audio_data).hexdigest()
|
328 |
+
|
329 |
+
if not ref_text.strip():
|
330 |
+
global _ref_audio_cache
|
331 |
+
if audio_hash in _ref_audio_cache:
|
332 |
+
# Use cached asr transcription
|
333 |
+
show_info("Using cached reference text...")
|
334 |
+
ref_text = _ref_audio_cache[audio_hash]
|
335 |
+
else:
|
336 |
+
show_info("No reference text provided, transcribing reference audio...")
|
337 |
+
ref_text = transcribe(ref_audio)
|
338 |
+
# Cache the transcribed text (not caching custom ref_text, enabling users to do manual tweak)
|
339 |
+
_ref_audio_cache[audio_hash] = ref_text
|
340 |
+
else:
|
341 |
+
# show_info("Using custom reference text...")
|
342 |
+
pass
|
343 |
+
|
344 |
+
# Ensure ref_text ends with a proper sentence-ending punctuation
|
345 |
+
if not ref_text.endswith(". ") and not ref_text.endswith("。"):
|
346 |
+
if ref_text.endswith("."):
|
347 |
+
ref_text += " "
|
348 |
+
else:
|
349 |
+
ref_text += ". "
|
350 |
+
|
351 |
+
# print("\nref_text ", ref_text)
|
352 |
+
|
353 |
+
return ref_audio, ref_text
|
354 |
+
|
355 |
+
|
356 |
+
# infer process: chunk text -> infer batches [i.e. infer_batch_process()]
|
357 |
+
|
358 |
+
|
359 |
+
def infer_process(
|
360 |
+
ref_audio,
|
361 |
+
ref_text,
|
362 |
+
gen_text,
|
363 |
+
model_obj,
|
364 |
+
vocoder,
|
365 |
+
mel_spec_type=mel_spec_type,
|
366 |
+
show_info=print,
|
367 |
+
progress=tqdm,
|
368 |
+
target_rms=target_rms,
|
369 |
+
cross_fade_duration=cross_fade_duration,
|
370 |
+
nfe_step=nfe_step,
|
371 |
+
cfg_strength=cfg_strength,
|
372 |
+
sway_sampling_coef=sway_sampling_coef,
|
373 |
+
speed=speed,
|
374 |
+
fix_duration=fix_duration,
|
375 |
+
device=device,
|
376 |
+
):
|
377 |
+
# Split the input text into batches
|
378 |
+
audio, sr = torchaudio.load(ref_audio)
|
379 |
+
max_chars = int(len(ref_text.encode("utf-8")) / (audio.shape[-1] / sr) * (25 - audio.shape[-1] / sr))
|
380 |
+
gen_text_batches = chunk_text(gen_text, max_chars=max_chars)
|
381 |
+
# for i, gen_text in enumerate(gen_text_batches):
|
382 |
+
# print(f"gen_text {i}", gen_text)
|
383 |
+
# print("\n")
|
384 |
+
|
385 |
+
# show_info(f"Generating audio in {len(gen_text_batches)} batches...")
|
386 |
+
return infer_batch_process(
|
387 |
+
(audio, sr),
|
388 |
+
ref_text,
|
389 |
+
gen_text_batches,
|
390 |
+
model_obj,
|
391 |
+
vocoder,
|
392 |
+
mel_spec_type=mel_spec_type,
|
393 |
+
progress=progress,
|
394 |
+
target_rms=target_rms,
|
395 |
+
cross_fade_duration=cross_fade_duration,
|
396 |
+
nfe_step=nfe_step,
|
397 |
+
cfg_strength=cfg_strength,
|
398 |
+
sway_sampling_coef=sway_sampling_coef,
|
399 |
+
speed=speed,
|
400 |
+
fix_duration=fix_duration,
|
401 |
+
device=device,
|
402 |
+
)
|
403 |
+
|
404 |
+
|
405 |
+
# infer batches
|
406 |
+
|
407 |
+
|
408 |
+
def infer_batch_process(
|
409 |
+
ref_audio,
|
410 |
+
ref_text,
|
411 |
+
gen_text_batches,
|
412 |
+
model_obj,
|
413 |
+
vocoder,
|
414 |
+
mel_spec_type="vocos",
|
415 |
+
progress=tqdm,
|
416 |
+
target_rms=0.1,
|
417 |
+
cross_fade_duration=0.15,
|
418 |
+
nfe_step=32,
|
419 |
+
cfg_strength=2.0,
|
420 |
+
sway_sampling_coef=-1,
|
421 |
+
speed=1,
|
422 |
+
fix_duration=None,
|
423 |
+
device=None,
|
424 |
+
):
|
425 |
+
audio, sr = ref_audio
|
426 |
+
if audio.shape[0] > 1:
|
427 |
+
audio = torch.mean(audio, dim=0, keepdim=True)
|
428 |
+
|
429 |
+
rms = torch.sqrt(torch.mean(torch.square(audio)))
|
430 |
+
if rms < target_rms:
|
431 |
+
audio = audio * target_rms / rms
|
432 |
+
if sr != target_sample_rate:
|
433 |
+
resampler = torchaudio.transforms.Resample(sr, target_sample_rate)
|
434 |
+
audio = resampler(audio)
|
435 |
+
audio = audio.to(device)
|
436 |
+
|
437 |
+
generated_waves = []
|
438 |
+
spectrograms = []
|
439 |
+
|
440 |
+
if len(ref_text[-1].encode("utf-8")) == 1:
|
441 |
+
ref_text = ref_text + " "
|
442 |
+
# for i, gen_text in enumerate(progress.tqdm(gen_text_batches)):
|
443 |
+
for i, gen_text in enumerate(gen_text_batches):
|
444 |
+
# Prepare the text
|
445 |
+
text_list = [ref_text + gen_text]
|
446 |
+
final_text_list = convert_char_to_pinyin(text_list)
|
447 |
+
|
448 |
+
ref_audio_len = audio.shape[-1] // hop_length
|
449 |
+
if fix_duration is not None:
|
450 |
+
duration = int(fix_duration * target_sample_rate / hop_length)
|
451 |
+
else:
|
452 |
+
# Calculate duration
|
453 |
+
ref_text_len = len(ref_text.encode("utf-8"))
|
454 |
+
gen_text_len = len(gen_text.encode("utf-8"))
|
455 |
+
duration = ref_audio_len + int(ref_audio_len / ref_text_len * gen_text_len / speed)
|
456 |
+
# print("ref_text_len:", ref_text_len)
|
457 |
+
# print("gen_text_len:", gen_text_len)
|
458 |
+
# print("duration:", duration)
|
459 |
+
# inference
|
460 |
+
with torch.inference_mode():
|
461 |
+
generated, _ = model_obj.sample(
|
462 |
+
cond=audio,
|
463 |
+
text=final_text_list,
|
464 |
+
duration=duration,
|
465 |
+
steps=nfe_step,
|
466 |
+
cfg_strength=cfg_strength,
|
467 |
+
sway_sampling_coef=sway_sampling_coef,
|
468 |
+
)
|
469 |
+
|
470 |
+
generated = generated.to(torch.float32)
|
471 |
+
generated = generated[:, ref_audio_len:, :]
|
472 |
+
generated_mel_spec = generated.permute(0, 2, 1)
|
473 |
+
if mel_spec_type == "vocos":
|
474 |
+
generated_wave = vocoder.decode(generated_mel_spec)
|
475 |
+
elif mel_spec_type == "bigvgan":
|
476 |
+
generated_wave = vocoder(generated_mel_spec)
|
477 |
+
if rms < target_rms:
|
478 |
+
generated_wave = generated_wave * rms / target_rms
|
479 |
+
|
480 |
+
# wav -> numpy
|
481 |
+
generated_wave = generated_wave.squeeze().cpu().numpy()
|
482 |
+
|
483 |
+
generated_waves.append(generated_wave)
|
484 |
+
spectrograms.append(generated_mel_spec[0].cpu().numpy())
|
485 |
+
|
486 |
+
# Combine all generated waves with cross-fading
|
487 |
+
if cross_fade_duration <= 0:
|
488 |
+
# Simply concatenate
|
489 |
+
final_wave = np.concatenate(generated_waves)
|
490 |
+
else:
|
491 |
+
final_wave = generated_waves[0]
|
492 |
+
for i in range(1, len(generated_waves)):
|
493 |
+
prev_wave = final_wave
|
494 |
+
next_wave = generated_waves[i]
|
495 |
+
|
496 |
+
# Calculate cross-fade samples, ensuring it does not exceed wave lengths
|
497 |
+
cross_fade_samples = int(cross_fade_duration * target_sample_rate)
|
498 |
+
cross_fade_samples = min(cross_fade_samples, len(prev_wave), len(next_wave))
|
499 |
+
|
500 |
+
if cross_fade_samples <= 0:
|
501 |
+
# No overlap possible, concatenate
|
502 |
+
final_wave = np.concatenate([prev_wave, next_wave])
|
503 |
+
continue
|
504 |
+
|
505 |
+
# Overlapping parts
|
506 |
+
prev_overlap = prev_wave[-cross_fade_samples:]
|
507 |
+
next_overlap = next_wave[:cross_fade_samples]
|
508 |
+
|
509 |
+
# Fade out and fade in
|
510 |
+
fade_out = np.linspace(1, 0, cross_fade_samples)
|
511 |
+
fade_in = np.linspace(0, 1, cross_fade_samples)
|
512 |
+
|
513 |
+
# Cross-faded overlap
|
514 |
+
cross_faded_overlap = prev_overlap * fade_out + next_overlap * fade_in
|
515 |
+
|
516 |
+
# Combine
|
517 |
+
new_wave = np.concatenate(
|
518 |
+
[prev_wave[:-cross_fade_samples], cross_faded_overlap, next_wave[cross_fade_samples:]]
|
519 |
+
)
|
520 |
+
|
521 |
+
final_wave = new_wave
|
522 |
+
|
523 |
+
# Create a combined spectrogram
|
524 |
+
combined_spectrogram = np.concatenate(spectrograms, axis=1)
|
525 |
+
|
526 |
+
return final_wave, target_sample_rate, combined_spectrogram
|
527 |
+
|
528 |
+
|
529 |
+
# remove silence from generated wav
|
530 |
+
|
531 |
+
|
532 |
+
def remove_silence_for_generated_wav(filename):
|
533 |
+
aseg = AudioSegment.from_file(filename)
|
534 |
+
non_silent_segs = silence.split_on_silence(
|
535 |
+
aseg, min_silence_len=1000, silence_thresh=-50, keep_silence=500, seek_step=10
|
536 |
+
)
|
537 |
+
non_silent_wave = AudioSegment.silent(duration=0)
|
538 |
+
for non_silent_seg in non_silent_segs:
|
539 |
+
non_silent_wave += non_silent_seg
|
540 |
+
aseg = non_silent_wave
|
541 |
+
aseg.export(filename, format="wav")
|
542 |
+
|
543 |
+
|
544 |
+
# save spectrogram
|
545 |
+
|
546 |
+
|
547 |
+
def save_spectrogram(spectrogram, path):
|
548 |
+
plt.figure(figsize=(12, 4))
|
549 |
+
plt.imshow(spectrogram, origin="lower", aspect="auto")
|
550 |
+
plt.colorbar()
|
551 |
+
plt.savefig(path)
|
552 |
+
plt.close()
|
f5_tts/model/__init__.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from f5_tts.model.cfm import CFM
|
2 |
+
|
3 |
+
from f5_tts.model.backbones.unett import UNetT
|
4 |
+
from f5_tts.model.backbones.dit import DiT
|
5 |
+
from f5_tts.model.backbones.mmdit import MMDiT
|
6 |
+
|
7 |
+
from f5_tts.model.trainer import Trainer
|
8 |
+
|
9 |
+
|
10 |
+
__all__ = ["CFM", "UNetT", "DiT", "MMDiT", "Trainer"]
|
f5_tts/model/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (471 Bytes). View file
|
|
f5_tts/model/__pycache__/cfm.cpython-310.pyc
ADDED
Binary file (5.49 kB). View file
|
|
f5_tts/model/__pycache__/dataset.cpython-310.pyc
ADDED
Binary file (8.61 kB). View file
|
|
f5_tts/model/__pycache__/modules.cpython-310.pyc
ADDED
Binary file (16.6 kB). View file
|
|
f5_tts/model/__pycache__/trainer.cpython-310.pyc
ADDED
Binary file (9.89 kB). View file
|
|
f5_tts/model/__pycache__/utils.cpython-310.pyc
ADDED
Binary file (6.28 kB). View file
|
|
f5_tts/model/backbones/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Backbones quick introduction
|
2 |
+
|
3 |
+
|
4 |
+
### unett.py
|
5 |
+
- flat unet transformer
|
6 |
+
- structure same as in e2-tts & voicebox paper except using rotary pos emb
|
7 |
+
- update: allow possible abs pos emb & convnextv2 blocks for embedded text before concat
|
8 |
+
|
9 |
+
### dit.py
|
10 |
+
- adaln-zero dit
|
11 |
+
- embedded timestep as condition
|
12 |
+
- concatted noised_input + masked_cond + embedded_text, linear proj in
|
13 |
+
- possible abs pos emb & convnextv2 blocks for embedded text before concat
|
14 |
+
- possible long skip connection (first layer to last layer)
|
15 |
+
|
16 |
+
### mmdit.py
|
17 |
+
- sd3 structure
|
18 |
+
- timestep as condition
|
19 |
+
- left stream: text embedded and applied a abs pos emb
|
20 |
+
- right stream: masked_cond & noised_input concatted and with same conv pos emb as unett
|
f5_tts/model/backbones/__pycache__/dit.cpython-310.pyc
ADDED
Binary file (4.55 kB). View file
|
|
f5_tts/model/backbones/__pycache__/mmdit.cpython-310.pyc
ADDED
Binary file (3.95 kB). View file
|
|
f5_tts/model/backbones/__pycache__/unett.cpython-310.pyc
ADDED
Binary file (5.27 kB). View file
|
|
f5_tts/model/backbones/dit.py
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
ein notation:
|
3 |
+
b - batch
|
4 |
+
n - sequence
|
5 |
+
nt - text sequence
|
6 |
+
nw - raw wave length
|
7 |
+
d - dimension
|
8 |
+
"""
|
9 |
+
|
10 |
+
from __future__ import annotations
|
11 |
+
|
12 |
+
import torch
|
13 |
+
from torch import nn
|
14 |
+
import torch.nn.functional as F
|
15 |
+
|
16 |
+
from x_transformers.x_transformers import RotaryEmbedding
|
17 |
+
|
18 |
+
from f5_tts.model.modules import (
|
19 |
+
TimestepEmbedding,
|
20 |
+
ConvNeXtV2Block,
|
21 |
+
ConvPositionEmbedding,
|
22 |
+
DiTBlock,
|
23 |
+
AdaLayerNormZero_Final,
|
24 |
+
precompute_freqs_cis,
|
25 |
+
get_pos_embed_indices,
|
26 |
+
)
|
27 |
+
|
28 |
+
|
29 |
+
# Text embedding
|
30 |
+
|
31 |
+
|
32 |
+
class TextEmbedding(nn.Module):
|
33 |
+
def __init__(self, text_num_embeds, text_dim, conv_layers=0, conv_mult=2):
|
34 |
+
super().__init__()
|
35 |
+
self.text_embed = nn.Embedding(text_num_embeds + 1, text_dim) # use 0 as filler token
|
36 |
+
|
37 |
+
if conv_layers > 0:
|
38 |
+
self.extra_modeling = True
|
39 |
+
self.precompute_max_pos = 4096 # ~44s of 24khz audio
|
40 |
+
self.register_buffer("freqs_cis", precompute_freqs_cis(text_dim, self.precompute_max_pos), persistent=False)
|
41 |
+
self.text_blocks = nn.Sequential(
|
42 |
+
*[ConvNeXtV2Block(text_dim, text_dim * conv_mult) for _ in range(conv_layers)]
|
43 |
+
)
|
44 |
+
else:
|
45 |
+
self.extra_modeling = False
|
46 |
+
|
47 |
+
def forward(self, text: int["b nt"], seq_len, drop_text=False): # noqa: F722
|
48 |
+
text = text + 1 # use 0 as filler token. preprocess of batch pad -1, see list_str_to_idx()
|
49 |
+
text = text[:, :seq_len] # curtail if character tokens are more than the mel spec tokens
|
50 |
+
batch, text_len = text.shape[0], text.shape[1]
|
51 |
+
text = F.pad(text, (0, seq_len - text_len), value=0)
|
52 |
+
|
53 |
+
if drop_text: # cfg for text
|
54 |
+
text = torch.zeros_like(text)
|
55 |
+
|
56 |
+
text = self.text_embed(text) # b n -> b n d
|
57 |
+
|
58 |
+
# possible extra modeling
|
59 |
+
if self.extra_modeling:
|
60 |
+
# sinus pos emb
|
61 |
+
batch_start = torch.zeros((batch,), dtype=torch.long)
|
62 |
+
pos_idx = get_pos_embed_indices(batch_start, seq_len, max_pos=self.precompute_max_pos)
|
63 |
+
text_pos_embed = self.freqs_cis[pos_idx]
|
64 |
+
text = text + text_pos_embed
|
65 |
+
|
66 |
+
# convnextv2 blocks
|
67 |
+
text = self.text_blocks(text)
|
68 |
+
|
69 |
+
return text
|
70 |
+
|
71 |
+
|
72 |
+
# noised input audio and context mixing embedding
|
73 |
+
|
74 |
+
|
75 |
+
class InputEmbedding(nn.Module):
|
76 |
+
def __init__(self, mel_dim, text_dim, out_dim):
|
77 |
+
super().__init__()
|
78 |
+
self.proj = nn.Linear(mel_dim * 2 + text_dim, out_dim)
|
79 |
+
self.conv_pos_embed = ConvPositionEmbedding(dim=out_dim)
|
80 |
+
|
81 |
+
def forward(self, x: float["b n d"], cond: float["b n d"], text_embed: float["b n d"], drop_audio_cond=False): # noqa: F722
|
82 |
+
if drop_audio_cond: # cfg for cond audio
|
83 |
+
cond = torch.zeros_like(cond)
|
84 |
+
|
85 |
+
x = self.proj(torch.cat((x, cond, text_embed), dim=-1))
|
86 |
+
x = self.conv_pos_embed(x) + x
|
87 |
+
return x
|
88 |
+
|
89 |
+
|
90 |
+
# Transformer backbone using DiT blocks
|
91 |
+
|
92 |
+
|
93 |
+
class DiT(nn.Module):
|
94 |
+
def __init__(
|
95 |
+
self,
|
96 |
+
*,
|
97 |
+
dim,
|
98 |
+
depth=8,
|
99 |
+
heads=8,
|
100 |
+
dim_head=64,
|
101 |
+
dropout=0.1,
|
102 |
+
ff_mult=4,
|
103 |
+
mel_dim=100,
|
104 |
+
text_num_embeds=256,
|
105 |
+
text_dim=None,
|
106 |
+
conv_layers=0,
|
107 |
+
long_skip_connection=False,
|
108 |
+
):
|
109 |
+
super().__init__()
|
110 |
+
|
111 |
+
self.time_embed = TimestepEmbedding(dim)
|
112 |
+
if text_dim is None:
|
113 |
+
text_dim = mel_dim
|
114 |
+
self.text_embed = TextEmbedding(text_num_embeds, text_dim, conv_layers=conv_layers)
|
115 |
+
self.input_embed = InputEmbedding(mel_dim, text_dim, dim)
|
116 |
+
|
117 |
+
self.rotary_embed = RotaryEmbedding(dim_head)
|
118 |
+
|
119 |
+
self.dim = dim
|
120 |
+
self.depth = depth
|
121 |
+
|
122 |
+
self.transformer_blocks = nn.ModuleList(
|
123 |
+
[DiTBlock(dim=dim, heads=heads, dim_head=dim_head, ff_mult=ff_mult, dropout=dropout) for _ in range(depth)]
|
124 |
+
)
|
125 |
+
self.long_skip_connection = nn.Linear(dim * 2, dim, bias=False) if long_skip_connection else None
|
126 |
+
|
127 |
+
self.norm_out = AdaLayerNormZero_Final(dim) # final modulation
|
128 |
+
self.proj_out = nn.Linear(dim, mel_dim)
|
129 |
+
|
130 |
+
def forward(
|
131 |
+
self,
|
132 |
+
x: float["b n d"], # nosied input audio # noqa: F722
|
133 |
+
cond: float["b n d"], # masked cond audio # noqa: F722
|
134 |
+
text: int["b nt"], # text # noqa: F722
|
135 |
+
time: float["b"] | float[""], # time step # noqa: F821 F722
|
136 |
+
drop_audio_cond, # cfg for cond audio
|
137 |
+
drop_text, # cfg for text
|
138 |
+
mask: bool["b n"] | None = None, # noqa: F722
|
139 |
+
):
|
140 |
+
batch, seq_len = x.shape[0], x.shape[1]
|
141 |
+
if time.ndim == 0:
|
142 |
+
time = time.repeat(batch)
|
143 |
+
|
144 |
+
# t: conditioning time, c: context (text + masked cond audio), x: noised input audio
|
145 |
+
t = self.time_embed(time)
|
146 |
+
text_embed = self.text_embed(text, seq_len, drop_text=drop_text)
|
147 |
+
x = self.input_embed(x, cond, text_embed, drop_audio_cond=drop_audio_cond)
|
148 |
+
|
149 |
+
rope = self.rotary_embed.forward_from_seq_len(seq_len)
|
150 |
+
|
151 |
+
if self.long_skip_connection is not None:
|
152 |
+
residual = x
|
153 |
+
|
154 |
+
for block in self.transformer_blocks:
|
155 |
+
x = block(x, t, mask=mask, rope=rope)
|
156 |
+
|
157 |
+
if self.long_skip_connection is not None:
|
158 |
+
x = self.long_skip_connection(torch.cat((x, residual), dim=-1))
|
159 |
+
|
160 |
+
x = self.norm_out(x, t)
|
161 |
+
output = self.proj_out(x)
|
162 |
+
|
163 |
+
return output
|
f5_tts/model/backbones/mmdit.py
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
ein notation:
|
3 |
+
b - batch
|
4 |
+
n - sequence
|
5 |
+
nt - text sequence
|
6 |
+
nw - raw wave length
|
7 |
+
d - dimension
|
8 |
+
"""
|
9 |
+
|
10 |
+
from __future__ import annotations
|
11 |
+
|
12 |
+
import torch
|
13 |
+
from torch import nn
|
14 |
+
|
15 |
+
from x_transformers.x_transformers import RotaryEmbedding
|
16 |
+
|
17 |
+
from f5_tts.model.modules import (
|
18 |
+
TimestepEmbedding,
|
19 |
+
ConvPositionEmbedding,
|
20 |
+
MMDiTBlock,
|
21 |
+
AdaLayerNormZero_Final,
|
22 |
+
precompute_freqs_cis,
|
23 |
+
get_pos_embed_indices,
|
24 |
+
)
|
25 |
+
|
26 |
+
|
27 |
+
# text embedding
|
28 |
+
|
29 |
+
|
30 |
+
class TextEmbedding(nn.Module):
|
31 |
+
def __init__(self, out_dim, text_num_embeds):
|
32 |
+
super().__init__()
|
33 |
+
self.text_embed = nn.Embedding(text_num_embeds + 1, out_dim) # will use 0 as filler token
|
34 |
+
|
35 |
+
self.precompute_max_pos = 1024
|
36 |
+
self.register_buffer("freqs_cis", precompute_freqs_cis(out_dim, self.precompute_max_pos), persistent=False)
|
37 |
+
|
38 |
+
def forward(self, text: int["b nt"], drop_text=False) -> int["b nt d"]: # noqa: F722
|
39 |
+
text = text + 1
|
40 |
+
if drop_text:
|
41 |
+
text = torch.zeros_like(text)
|
42 |
+
text = self.text_embed(text)
|
43 |
+
|
44 |
+
# sinus pos emb
|
45 |
+
batch_start = torch.zeros((text.shape[0],), dtype=torch.long)
|
46 |
+
batch_text_len = text.shape[1]
|
47 |
+
pos_idx = get_pos_embed_indices(batch_start, batch_text_len, max_pos=self.precompute_max_pos)
|
48 |
+
text_pos_embed = self.freqs_cis[pos_idx]
|
49 |
+
|
50 |
+
text = text + text_pos_embed
|
51 |
+
|
52 |
+
return text
|
53 |
+
|
54 |
+
|
55 |
+
# noised input & masked cond audio embedding
|
56 |
+
|
57 |
+
|
58 |
+
class AudioEmbedding(nn.Module):
|
59 |
+
def __init__(self, in_dim, out_dim):
|
60 |
+
super().__init__()
|
61 |
+
self.linear = nn.Linear(2 * in_dim, out_dim)
|
62 |
+
self.conv_pos_embed = ConvPositionEmbedding(out_dim)
|
63 |
+
|
64 |
+
def forward(self, x: float["b n d"], cond: float["b n d"], drop_audio_cond=False): # noqa: F722
|
65 |
+
if drop_audio_cond:
|
66 |
+
cond = torch.zeros_like(cond)
|
67 |
+
x = torch.cat((x, cond), dim=-1)
|
68 |
+
x = self.linear(x)
|
69 |
+
x = self.conv_pos_embed(x) + x
|
70 |
+
return x
|
71 |
+
|
72 |
+
|
73 |
+
# Transformer backbone using MM-DiT blocks
|
74 |
+
|
75 |
+
|
76 |
+
class MMDiT(nn.Module):
|
77 |
+
def __init__(
|
78 |
+
self,
|
79 |
+
*,
|
80 |
+
dim,
|
81 |
+
depth=8,
|
82 |
+
heads=8,
|
83 |
+
dim_head=64,
|
84 |
+
dropout=0.1,
|
85 |
+
ff_mult=4,
|
86 |
+
text_num_embeds=256,
|
87 |
+
mel_dim=100,
|
88 |
+
):
|
89 |
+
super().__init__()
|
90 |
+
|
91 |
+
self.time_embed = TimestepEmbedding(dim)
|
92 |
+
self.text_embed = TextEmbedding(dim, text_num_embeds)
|
93 |
+
self.audio_embed = AudioEmbedding(mel_dim, dim)
|
94 |
+
|
95 |
+
self.rotary_embed = RotaryEmbedding(dim_head)
|
96 |
+
|
97 |
+
self.dim = dim
|
98 |
+
self.depth = depth
|
99 |
+
|
100 |
+
self.transformer_blocks = nn.ModuleList(
|
101 |
+
[
|
102 |
+
MMDiTBlock(
|
103 |
+
dim=dim,
|
104 |
+
heads=heads,
|
105 |
+
dim_head=dim_head,
|
106 |
+
dropout=dropout,
|
107 |
+
ff_mult=ff_mult,
|
108 |
+
context_pre_only=i == depth - 1,
|
109 |
+
)
|
110 |
+
for i in range(depth)
|
111 |
+
]
|
112 |
+
)
|
113 |
+
self.norm_out = AdaLayerNormZero_Final(dim) # final modulation
|
114 |
+
self.proj_out = nn.Linear(dim, mel_dim)
|
115 |
+
|
116 |
+
def forward(
|
117 |
+
self,
|
118 |
+
x: float["b n d"], # nosied input audio # noqa: F722
|
119 |
+
cond: float["b n d"], # masked cond audio # noqa: F722
|
120 |
+
text: int["b nt"], # text # noqa: F722
|
121 |
+
time: float["b"] | float[""], # time step # noqa: F821 F722
|
122 |
+
drop_audio_cond, # cfg for cond audio
|
123 |
+
drop_text, # cfg for text
|
124 |
+
mask: bool["b n"] | None = None, # noqa: F722
|
125 |
+
):
|
126 |
+
batch = x.shape[0]
|
127 |
+
if time.ndim == 0:
|
128 |
+
time = time.repeat(batch)
|
129 |
+
|
130 |
+
# t: conditioning (time), c: context (text + masked cond audio), x: noised input audio
|
131 |
+
t = self.time_embed(time)
|
132 |
+
c = self.text_embed(text, drop_text=drop_text)
|
133 |
+
x = self.audio_embed(x, cond, drop_audio_cond=drop_audio_cond)
|
134 |
+
|
135 |
+
seq_len = x.shape[1]
|
136 |
+
text_len = text.shape[1]
|
137 |
+
rope_audio = self.rotary_embed.forward_from_seq_len(seq_len)
|
138 |
+
rope_text = self.rotary_embed.forward_from_seq_len(text_len)
|
139 |
+
|
140 |
+
for block in self.transformer_blocks:
|
141 |
+
c, x = block(x, c, t, mask=mask, rope=rope_audio, c_rope=rope_text)
|
142 |
+
|
143 |
+
x = self.norm_out(x, t)
|
144 |
+
output = self.proj_out(x)
|
145 |
+
|
146 |
+
return output
|
f5_tts/model/backbones/unett.py
ADDED
@@ -0,0 +1,219 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
ein notation:
|
3 |
+
b - batch
|
4 |
+
n - sequence
|
5 |
+
nt - text sequence
|
6 |
+
nw - raw wave length
|
7 |
+
d - dimension
|
8 |
+
"""
|
9 |
+
|
10 |
+
from __future__ import annotations
|
11 |
+
from typing import Literal
|
12 |
+
|
13 |
+
import torch
|
14 |
+
from torch import nn
|
15 |
+
import torch.nn.functional as F
|
16 |
+
|
17 |
+
from x_transformers import RMSNorm
|
18 |
+
from x_transformers.x_transformers import RotaryEmbedding
|
19 |
+
|
20 |
+
from f5_tts.model.modules import (
|
21 |
+
TimestepEmbedding,
|
22 |
+
ConvNeXtV2Block,
|
23 |
+
ConvPositionEmbedding,
|
24 |
+
Attention,
|
25 |
+
AttnProcessor,
|
26 |
+
FeedForward,
|
27 |
+
precompute_freqs_cis,
|
28 |
+
get_pos_embed_indices,
|
29 |
+
)
|
30 |
+
|
31 |
+
|
32 |
+
# Text embedding
|
33 |
+
|
34 |
+
|
35 |
+
class TextEmbedding(nn.Module):
|
36 |
+
def __init__(self, text_num_embeds, text_dim, conv_layers=0, conv_mult=2):
|
37 |
+
super().__init__()
|
38 |
+
self.text_embed = nn.Embedding(text_num_embeds + 1, text_dim) # use 0 as filler token
|
39 |
+
|
40 |
+
if conv_layers > 0:
|
41 |
+
self.extra_modeling = True
|
42 |
+
self.precompute_max_pos = 4096 # ~44s of 24khz audio
|
43 |
+
self.register_buffer("freqs_cis", precompute_freqs_cis(text_dim, self.precompute_max_pos), persistent=False)
|
44 |
+
self.text_blocks = nn.Sequential(
|
45 |
+
*[ConvNeXtV2Block(text_dim, text_dim * conv_mult) for _ in range(conv_layers)]
|
46 |
+
)
|
47 |
+
else:
|
48 |
+
self.extra_modeling = False
|
49 |
+
|
50 |
+
def forward(self, text: int["b nt"], seq_len, drop_text=False): # noqa: F722
|
51 |
+
text = text + 1 # use 0 as filler token. preprocess of batch pad -1, see list_str_to_idx()
|
52 |
+
text = text[:, :seq_len] # curtail if character tokens are more than the mel spec tokens
|
53 |
+
batch, text_len = text.shape[0], text.shape[1]
|
54 |
+
text = F.pad(text, (0, seq_len - text_len), value=0)
|
55 |
+
|
56 |
+
if drop_text: # cfg for text
|
57 |
+
text = torch.zeros_like(text)
|
58 |
+
|
59 |
+
text = self.text_embed(text) # b n -> b n d
|
60 |
+
|
61 |
+
# possible extra modeling
|
62 |
+
if self.extra_modeling:
|
63 |
+
# sinus pos emb
|
64 |
+
batch_start = torch.zeros((batch,), dtype=torch.long)
|
65 |
+
pos_idx = get_pos_embed_indices(batch_start, seq_len, max_pos=self.precompute_max_pos)
|
66 |
+
text_pos_embed = self.freqs_cis[pos_idx]
|
67 |
+
text = text + text_pos_embed
|
68 |
+
|
69 |
+
# convnextv2 blocks
|
70 |
+
text = self.text_blocks(text)
|
71 |
+
|
72 |
+
return text
|
73 |
+
|
74 |
+
|
75 |
+
# noised input audio and context mixing embedding
|
76 |
+
|
77 |
+
|
78 |
+
class InputEmbedding(nn.Module):
|
79 |
+
def __init__(self, mel_dim, text_dim, out_dim):
|
80 |
+
super().__init__()
|
81 |
+
self.proj = nn.Linear(mel_dim * 2 + text_dim, out_dim)
|
82 |
+
self.conv_pos_embed = ConvPositionEmbedding(dim=out_dim)
|
83 |
+
|
84 |
+
def forward(self, x: float["b n d"], cond: float["b n d"], text_embed: float["b n d"], drop_audio_cond=False): # noqa: F722
|
85 |
+
if drop_audio_cond: # cfg for cond audio
|
86 |
+
cond = torch.zeros_like(cond)
|
87 |
+
|
88 |
+
x = self.proj(torch.cat((x, cond, text_embed), dim=-1))
|
89 |
+
x = self.conv_pos_embed(x) + x
|
90 |
+
return x
|
91 |
+
|
92 |
+
|
93 |
+
# Flat UNet Transformer backbone
|
94 |
+
|
95 |
+
|
96 |
+
class UNetT(nn.Module):
|
97 |
+
def __init__(
|
98 |
+
self,
|
99 |
+
*,
|
100 |
+
dim,
|
101 |
+
depth=8,
|
102 |
+
heads=8,
|
103 |
+
dim_head=64,
|
104 |
+
dropout=0.1,
|
105 |
+
ff_mult=4,
|
106 |
+
mel_dim=100,
|
107 |
+
text_num_embeds=256,
|
108 |
+
text_dim=None,
|
109 |
+
conv_layers=0,
|
110 |
+
skip_connect_type: Literal["add", "concat", "none"] = "concat",
|
111 |
+
):
|
112 |
+
super().__init__()
|
113 |
+
assert depth % 2 == 0, "UNet-Transformer's depth should be even."
|
114 |
+
|
115 |
+
self.time_embed = TimestepEmbedding(dim)
|
116 |
+
if text_dim is None:
|
117 |
+
text_dim = mel_dim
|
118 |
+
self.text_embed = TextEmbedding(text_num_embeds, text_dim, conv_layers=conv_layers)
|
119 |
+
self.input_embed = InputEmbedding(mel_dim, text_dim, dim)
|
120 |
+
|
121 |
+
self.rotary_embed = RotaryEmbedding(dim_head)
|
122 |
+
|
123 |
+
# transformer layers & skip connections
|
124 |
+
|
125 |
+
self.dim = dim
|
126 |
+
self.skip_connect_type = skip_connect_type
|
127 |
+
needs_skip_proj = skip_connect_type == "concat"
|
128 |
+
|
129 |
+
self.depth = depth
|
130 |
+
self.layers = nn.ModuleList([])
|
131 |
+
|
132 |
+
for idx in range(depth):
|
133 |
+
is_later_half = idx >= (depth // 2)
|
134 |
+
|
135 |
+
attn_norm = RMSNorm(dim)
|
136 |
+
attn = Attention(
|
137 |
+
processor=AttnProcessor(),
|
138 |
+
dim=dim,
|
139 |
+
heads=heads,
|
140 |
+
dim_head=dim_head,
|
141 |
+
dropout=dropout,
|
142 |
+
)
|
143 |
+
|
144 |
+
ff_norm = RMSNorm(dim)
|
145 |
+
ff = FeedForward(dim=dim, mult=ff_mult, dropout=dropout, approximate="tanh")
|
146 |
+
|
147 |
+
skip_proj = nn.Linear(dim * 2, dim, bias=False) if needs_skip_proj and is_later_half else None
|
148 |
+
|
149 |
+
self.layers.append(
|
150 |
+
nn.ModuleList(
|
151 |
+
[
|
152 |
+
skip_proj,
|
153 |
+
attn_norm,
|
154 |
+
attn,
|
155 |
+
ff_norm,
|
156 |
+
ff,
|
157 |
+
]
|
158 |
+
)
|
159 |
+
)
|
160 |
+
|
161 |
+
self.norm_out = RMSNorm(dim)
|
162 |
+
self.proj_out = nn.Linear(dim, mel_dim)
|
163 |
+
|
164 |
+
def forward(
|
165 |
+
self,
|
166 |
+
x: float["b n d"], # nosied input audio # noqa: F722
|
167 |
+
cond: float["b n d"], # masked cond audio # noqa: F722
|
168 |
+
text: int["b nt"], # text # noqa: F722
|
169 |
+
time: float["b"] | float[""], # time step # noqa: F821 F722
|
170 |
+
drop_audio_cond, # cfg for cond audio
|
171 |
+
drop_text, # cfg for text
|
172 |
+
mask: bool["b n"] | None = None, # noqa: F722
|
173 |
+
):
|
174 |
+
batch, seq_len = x.shape[0], x.shape[1]
|
175 |
+
if time.ndim == 0:
|
176 |
+
time = time.repeat(batch)
|
177 |
+
|
178 |
+
# t: conditioning time, c: context (text + masked cond audio), x: noised input audio
|
179 |
+
t = self.time_embed(time)
|
180 |
+
text_embed = self.text_embed(text, seq_len, drop_text=drop_text)
|
181 |
+
x = self.input_embed(x, cond, text_embed, drop_audio_cond=drop_audio_cond)
|
182 |
+
|
183 |
+
# postfix time t to input x, [b n d] -> [b n+1 d]
|
184 |
+
x = torch.cat([t.unsqueeze(1), x], dim=1) # pack t to x
|
185 |
+
if mask is not None:
|
186 |
+
mask = F.pad(mask, (1, 0), value=1)
|
187 |
+
|
188 |
+
rope = self.rotary_embed.forward_from_seq_len(seq_len + 1)
|
189 |
+
|
190 |
+
# flat unet transformer
|
191 |
+
skip_connect_type = self.skip_connect_type
|
192 |
+
skips = []
|
193 |
+
for idx, (maybe_skip_proj, attn_norm, attn, ff_norm, ff) in enumerate(self.layers):
|
194 |
+
layer = idx + 1
|
195 |
+
|
196 |
+
# skip connection logic
|
197 |
+
is_first_half = layer <= (self.depth // 2)
|
198 |
+
is_later_half = not is_first_half
|
199 |
+
|
200 |
+
if is_first_half:
|
201 |
+
skips.append(x)
|
202 |
+
|
203 |
+
if is_later_half:
|
204 |
+
skip = skips.pop()
|
205 |
+
if skip_connect_type == "concat":
|
206 |
+
x = torch.cat((x, skip), dim=-1)
|
207 |
+
x = maybe_skip_proj(x)
|
208 |
+
elif skip_connect_type == "add":
|
209 |
+
x = x + skip
|
210 |
+
|
211 |
+
# attention and feedforward blocks
|
212 |
+
x = attn(attn_norm(x), rope=rope, mask=mask) + x
|
213 |
+
x = ff(ff_norm(x)) + x
|
214 |
+
|
215 |
+
assert len(skips) == 0
|
216 |
+
|
217 |
+
x = self.norm_out(x)[:, 1:, :] # unpack t from x
|
218 |
+
|
219 |
+
return self.proj_out(x)
|