xinference 0.14.3__py3-none-any.whl → 0.14.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xinference might be problematic. Click here for more details.
- xinference/_version.py +3 -3
- xinference/core/worker.py +18 -9
- xinference/model/audio/chattts.py +4 -3
- xinference/model/audio/cosyvoice.py +4 -3
- xinference/model/audio/custom.py +4 -5
- xinference/model/embedding/core.py +2 -0
- xinference/model/embedding/custom.py +4 -5
- xinference/model/flexible/core.py +5 -1
- xinference/model/image/custom.py +4 -5
- xinference/model/image/stable_diffusion/core.py +21 -6
- xinference/model/llm/llm_family.py +5 -6
- xinference/model/llm/sglang/core.py +7 -1
- xinference/model/llm/transformers/core.py +2 -0
- xinference/model/llm/utils.py +3 -0
- xinference/model/llm/vllm/core.py +0 -33
- xinference/model/rerank/custom.py +4 -5
- xinference/model/utils.py +41 -1
- xinference/model/video/core.py +3 -1
- xinference/model/video/diffusers.py +41 -38
- xinference/model/video/model_spec.json +24 -1
- xinference/model/video/model_spec_modelscope.json +25 -1
- xinference/thirdparty/fish_speech/tools/api.py +1 -1
- xinference/thirdparty/matcha/__init__.py +0 -0
- xinference/thirdparty/matcha/app.py +357 -0
- xinference/thirdparty/matcha/cli.py +419 -0
- xinference/thirdparty/matcha/data/__init__.py +0 -0
- xinference/thirdparty/matcha/data/components/__init__.py +0 -0
- xinference/thirdparty/matcha/data/text_mel_datamodule.py +274 -0
- xinference/thirdparty/matcha/hifigan/__init__.py +0 -0
- xinference/thirdparty/matcha/hifigan/config.py +28 -0
- xinference/thirdparty/matcha/hifigan/denoiser.py +64 -0
- xinference/thirdparty/matcha/hifigan/env.py +17 -0
- xinference/thirdparty/matcha/hifigan/meldataset.py +217 -0
- xinference/thirdparty/matcha/hifigan/models.py +368 -0
- xinference/thirdparty/matcha/hifigan/xutils.py +60 -0
- xinference/thirdparty/matcha/models/__init__.py +0 -0
- xinference/thirdparty/matcha/models/baselightningmodule.py +210 -0
- xinference/thirdparty/matcha/models/components/__init__.py +0 -0
- xinference/thirdparty/matcha/models/components/decoder.py +443 -0
- xinference/thirdparty/matcha/models/components/flow_matching.py +132 -0
- xinference/thirdparty/matcha/models/components/text_encoder.py +410 -0
- xinference/thirdparty/matcha/models/components/transformer.py +316 -0
- xinference/thirdparty/matcha/models/matcha_tts.py +244 -0
- xinference/thirdparty/matcha/onnx/__init__.py +0 -0
- xinference/thirdparty/matcha/onnx/export.py +181 -0
- xinference/thirdparty/matcha/onnx/infer.py +168 -0
- xinference/thirdparty/matcha/text/__init__.py +53 -0
- xinference/thirdparty/matcha/text/cleaners.py +121 -0
- xinference/thirdparty/matcha/text/numbers.py +71 -0
- xinference/thirdparty/matcha/text/symbols.py +17 -0
- xinference/thirdparty/matcha/train.py +122 -0
- xinference/thirdparty/matcha/utils/__init__.py +5 -0
- xinference/thirdparty/matcha/utils/audio.py +82 -0
- xinference/thirdparty/matcha/utils/generate_data_statistics.py +112 -0
- xinference/thirdparty/matcha/utils/get_durations_from_trained_model.py +195 -0
- xinference/thirdparty/matcha/utils/instantiators.py +56 -0
- xinference/thirdparty/matcha/utils/logging_utils.py +53 -0
- xinference/thirdparty/matcha/utils/model.py +90 -0
- xinference/thirdparty/matcha/utils/monotonic_align/__init__.py +22 -0
- xinference/thirdparty/matcha/utils/monotonic_align/core.pyx +47 -0
- xinference/thirdparty/matcha/utils/monotonic_align/setup.py +7 -0
- xinference/thirdparty/matcha/utils/pylogger.py +21 -0
- xinference/thirdparty/matcha/utils/rich_utils.py +101 -0
- xinference/thirdparty/matcha/utils/utils.py +259 -0
- {xinference-0.14.3.dist-info → xinference-0.14.4.dist-info}/METADATA +20 -12
- {xinference-0.14.3.dist-info → xinference-0.14.4.dist-info}/RECORD +70 -28
- {xinference-0.14.3.dist-info → xinference-0.14.4.dist-info}/LICENSE +0 -0
- {xinference-0.14.3.dist-info → xinference-0.14.4.dist-info}/WHEEL +0 -0
- {xinference-0.14.3.dist-info → xinference-0.14.4.dist-info}/entry_points.txt +0 -0
- {xinference-0.14.3.dist-info → xinference-0.14.4.dist-info}/top_level.txt +0 -0
|
@@ -6,6 +6,29 @@
|
|
|
6
6
|
"model_revision": "4bbfb1de622b80bc1b77b6e9aced75f816be0e38",
|
|
7
7
|
"model_ability": [
|
|
8
8
|
"text2video"
|
|
9
|
-
]
|
|
9
|
+
],
|
|
10
|
+
"default_model_config": {
|
|
11
|
+
"scheduler": "CogVideoXDDIMScheduler",
|
|
12
|
+
"torch_dtype": "float16"
|
|
13
|
+
},
|
|
14
|
+
"default_generate_config": {
|
|
15
|
+
"guidance_scale": 6
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"model_name": "CogVideoX-5b",
|
|
20
|
+
"model_family": "CogVideoX",
|
|
21
|
+
"model_id": "THUDM/CogVideoX-5b",
|
|
22
|
+
"model_revision": "8d6ea3f817438460b25595a120f109b88d5fdfad",
|
|
23
|
+
"model_ability": [
|
|
24
|
+
"text2video"
|
|
25
|
+
],
|
|
26
|
+
"default_model_config": {
|
|
27
|
+
"scheduler": "CogVideoXDPMScheduler",
|
|
28
|
+
"torch_dtype": "bfloat16"
|
|
29
|
+
},
|
|
30
|
+
"default_generate_config": {
|
|
31
|
+
"guidance_scale": 7
|
|
32
|
+
}
|
|
10
33
|
}
|
|
11
34
|
]
|
|
@@ -7,6 +7,30 @@
|
|
|
7
7
|
"model_revision": "master",
|
|
8
8
|
"model_ability": [
|
|
9
9
|
"text2video"
|
|
10
|
-
]
|
|
10
|
+
],
|
|
11
|
+
"default_model_config": {
|
|
12
|
+
"scheduler": "CogVideoXDDIMScheduler",
|
|
13
|
+
"torch_dtype": "float16"
|
|
14
|
+
},
|
|
15
|
+
"default_generate_config": {
|
|
16
|
+
"guidance_scale": 6
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"model_name": "CogVideoX-5b",
|
|
21
|
+
"model_family": "CogVideoX",
|
|
22
|
+
"model_hub": "modelscope",
|
|
23
|
+
"model_id": "ZhipuAI/CogVideoX-5b",
|
|
24
|
+
"model_revision": "master",
|
|
25
|
+
"model_ability": [
|
|
26
|
+
"text2video"
|
|
27
|
+
],
|
|
28
|
+
"default_model_config": {
|
|
29
|
+
"scheduler": "CogVideoXDPMScheduler",
|
|
30
|
+
"torch_dtype": "bfloat16"
|
|
31
|
+
},
|
|
32
|
+
"default_generate_config": {
|
|
33
|
+
"guidance_scale": 7
|
|
34
|
+
}
|
|
11
35
|
}
|
|
12
36
|
]
|
|
@@ -34,7 +34,7 @@ from pydantic import BaseModel, Field
|
|
|
34
34
|
# from fish_speech.models.vqgan.lit_module import VQGAN
|
|
35
35
|
from fish_speech.models.vqgan.modules.firefly import FireflyArchitecture
|
|
36
36
|
from fish_speech.utils import autocast_exclude_mps
|
|
37
|
-
from tools.auto_rerank import batch_asr, calculate_wer, is_chinese, load_model
|
|
37
|
+
# from tools.auto_rerank import batch_asr, calculate_wer, is_chinese, load_model
|
|
38
38
|
from tools.llama.generate import (
|
|
39
39
|
GenerateRequest,
|
|
40
40
|
GenerateResponse,
|
|
File without changes
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import tempfile
|
|
2
|
+
from argparse import Namespace
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import gradio as gr
|
|
6
|
+
import soundfile as sf
|
|
7
|
+
import torch
|
|
8
|
+
|
|
9
|
+
from matcha.cli import (
|
|
10
|
+
MATCHA_URLS,
|
|
11
|
+
VOCODER_URLS,
|
|
12
|
+
assert_model_downloaded,
|
|
13
|
+
get_device,
|
|
14
|
+
load_matcha,
|
|
15
|
+
load_vocoder,
|
|
16
|
+
process_text,
|
|
17
|
+
to_waveform,
|
|
18
|
+
)
|
|
19
|
+
from matcha.utils.utils import get_user_data_dir, plot_tensor
|
|
20
|
+
|
|
21
|
+
LOCATION = Path(get_user_data_dir())
|
|
22
|
+
|
|
23
|
+
args = Namespace(
|
|
24
|
+
cpu=False,
|
|
25
|
+
model="matcha_vctk",
|
|
26
|
+
vocoder="hifigan_univ_v1",
|
|
27
|
+
spk=0,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
CURRENTLY_LOADED_MODEL = args.model
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def MATCHA_TTS_LOC(x):
|
|
34
|
+
return LOCATION / f"{x}.ckpt"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def VOCODER_LOC(x):
|
|
38
|
+
return LOCATION / f"{x}"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
LOGO_URL = "https://shivammehta25.github.io/Matcha-TTS/images/logo.png"
|
|
42
|
+
RADIO_OPTIONS = {
|
|
43
|
+
"Multi Speaker (VCTK)": {
|
|
44
|
+
"model": "matcha_vctk",
|
|
45
|
+
"vocoder": "hifigan_univ_v1",
|
|
46
|
+
},
|
|
47
|
+
"Single Speaker (LJ Speech)": {
|
|
48
|
+
"model": "matcha_ljspeech",
|
|
49
|
+
"vocoder": "hifigan_T2_v1",
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Ensure all the required models are downloaded
|
|
54
|
+
assert_model_downloaded(MATCHA_TTS_LOC("matcha_ljspeech"), MATCHA_URLS["matcha_ljspeech"])
|
|
55
|
+
assert_model_downloaded(VOCODER_LOC("hifigan_T2_v1"), VOCODER_URLS["hifigan_T2_v1"])
|
|
56
|
+
assert_model_downloaded(MATCHA_TTS_LOC("matcha_vctk"), MATCHA_URLS["matcha_vctk"])
|
|
57
|
+
assert_model_downloaded(VOCODER_LOC("hifigan_univ_v1"), VOCODER_URLS["hifigan_univ_v1"])
|
|
58
|
+
|
|
59
|
+
device = get_device(args)
|
|
60
|
+
|
|
61
|
+
# Load default model
|
|
62
|
+
model = load_matcha(args.model, MATCHA_TTS_LOC(args.model), device)
|
|
63
|
+
vocoder, denoiser = load_vocoder(args.vocoder, VOCODER_LOC(args.vocoder), device)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def load_model(model_name, vocoder_name):
|
|
67
|
+
model = load_matcha(model_name, MATCHA_TTS_LOC(model_name), device)
|
|
68
|
+
vocoder, denoiser = load_vocoder(vocoder_name, VOCODER_LOC(vocoder_name), device)
|
|
69
|
+
return model, vocoder, denoiser
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def load_model_ui(model_type, textbox):
|
|
73
|
+
model_name, vocoder_name = RADIO_OPTIONS[model_type]["model"], RADIO_OPTIONS[model_type]["vocoder"]
|
|
74
|
+
|
|
75
|
+
global model, vocoder, denoiser, CURRENTLY_LOADED_MODEL # pylint: disable=global-statement
|
|
76
|
+
if CURRENTLY_LOADED_MODEL != model_name:
|
|
77
|
+
model, vocoder, denoiser = load_model(model_name, vocoder_name)
|
|
78
|
+
CURRENTLY_LOADED_MODEL = model_name
|
|
79
|
+
|
|
80
|
+
if model_name == "matcha_ljspeech":
|
|
81
|
+
spk_slider = gr.update(visible=False, value=-1)
|
|
82
|
+
single_speaker_examples = gr.update(visible=True)
|
|
83
|
+
multi_speaker_examples = gr.update(visible=False)
|
|
84
|
+
length_scale = gr.update(value=0.95)
|
|
85
|
+
else:
|
|
86
|
+
spk_slider = gr.update(visible=True, value=0)
|
|
87
|
+
single_speaker_examples = gr.update(visible=False)
|
|
88
|
+
multi_speaker_examples = gr.update(visible=True)
|
|
89
|
+
length_scale = gr.update(value=0.85)
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
textbox,
|
|
93
|
+
gr.update(interactive=True),
|
|
94
|
+
spk_slider,
|
|
95
|
+
single_speaker_examples,
|
|
96
|
+
multi_speaker_examples,
|
|
97
|
+
length_scale,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@torch.inference_mode()
|
|
102
|
+
def process_text_gradio(text):
|
|
103
|
+
output = process_text(1, text, device)
|
|
104
|
+
return output["x_phones"][1::2], output["x"], output["x_lengths"]
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@torch.inference_mode()
|
|
108
|
+
def synthesise_mel(text, text_length, n_timesteps, temperature, length_scale, spk):
|
|
109
|
+
spk = torch.tensor([spk], device=device, dtype=torch.long) if spk >= 0 else None
|
|
110
|
+
output = model.synthesise(
|
|
111
|
+
text,
|
|
112
|
+
text_length,
|
|
113
|
+
n_timesteps=n_timesteps,
|
|
114
|
+
temperature=temperature,
|
|
115
|
+
spks=spk,
|
|
116
|
+
length_scale=length_scale,
|
|
117
|
+
)
|
|
118
|
+
output["waveform"] = to_waveform(output["mel"], vocoder, denoiser)
|
|
119
|
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
|
120
|
+
sf.write(fp.name, output["waveform"], 22050, "PCM_24")
|
|
121
|
+
|
|
122
|
+
return fp.name, plot_tensor(output["mel"].squeeze().cpu().numpy())
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def multispeaker_example_cacher(text, n_timesteps, mel_temp, length_scale, spk):
|
|
126
|
+
global CURRENTLY_LOADED_MODEL # pylint: disable=global-statement
|
|
127
|
+
if CURRENTLY_LOADED_MODEL != "matcha_vctk":
|
|
128
|
+
global model, vocoder, denoiser # pylint: disable=global-statement
|
|
129
|
+
model, vocoder, denoiser = load_model("matcha_vctk", "hifigan_univ_v1")
|
|
130
|
+
CURRENTLY_LOADED_MODEL = "matcha_vctk"
|
|
131
|
+
|
|
132
|
+
phones, text, text_lengths = process_text_gradio(text)
|
|
133
|
+
audio, mel_spectrogram = synthesise_mel(text, text_lengths, n_timesteps, mel_temp, length_scale, spk)
|
|
134
|
+
return phones, audio, mel_spectrogram
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def ljspeech_example_cacher(text, n_timesteps, mel_temp, length_scale, spk=-1):
|
|
138
|
+
global CURRENTLY_LOADED_MODEL # pylint: disable=global-statement
|
|
139
|
+
if CURRENTLY_LOADED_MODEL != "matcha_ljspeech":
|
|
140
|
+
global model, vocoder, denoiser # pylint: disable=global-statement
|
|
141
|
+
model, vocoder, denoiser = load_model("matcha_ljspeech", "hifigan_T2_v1")
|
|
142
|
+
CURRENTLY_LOADED_MODEL = "matcha_ljspeech"
|
|
143
|
+
|
|
144
|
+
phones, text, text_lengths = process_text_gradio(text)
|
|
145
|
+
audio, mel_spectrogram = synthesise_mel(text, text_lengths, n_timesteps, mel_temp, length_scale, spk)
|
|
146
|
+
return phones, audio, mel_spectrogram
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def main():
|
|
150
|
+
description = """# 🍵 Matcha-TTS: A fast TTS architecture with conditional flow matching
|
|
151
|
+
### [Shivam Mehta](https://www.kth.se/profile/smehta), [Ruibo Tu](https://www.kth.se/profile/ruibo), [Jonas Beskow](https://www.kth.se/profile/beskow), [Éva Székely](https://www.kth.se/profile/szekely), and [Gustav Eje Henter](https://people.kth.se/~ghe/)
|
|
152
|
+
We propose 🍵 Matcha-TTS, a new approach to non-autoregressive neural TTS, that uses conditional flow matching (similar to rectified flows) to speed up ODE-based speech synthesis. Our method:
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
* Is probabilistic
|
|
156
|
+
* Has compact memory footprint
|
|
157
|
+
* Sounds highly natural
|
|
158
|
+
* Is very fast to synthesise from
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
Check out our [demo page](https://shivammehta25.github.io/Matcha-TTS). Read our [arXiv preprint for more details](https://arxiv.org/abs/2309.03199).
|
|
162
|
+
Code is available in our [GitHub repository](https://github.com/shivammehta25/Matcha-TTS), along with pre-trained models.
|
|
163
|
+
|
|
164
|
+
Cached examples are available at the bottom of the page.
|
|
165
|
+
"""
|
|
166
|
+
|
|
167
|
+
with gr.Blocks(title="🍵 Matcha-TTS: A fast TTS architecture with conditional flow matching") as demo:
|
|
168
|
+
processed_text = gr.State(value=None)
|
|
169
|
+
processed_text_len = gr.State(value=None)
|
|
170
|
+
|
|
171
|
+
with gr.Box():
|
|
172
|
+
with gr.Row():
|
|
173
|
+
gr.Markdown(description, scale=3)
|
|
174
|
+
with gr.Column():
|
|
175
|
+
gr.Image(LOGO_URL, label="Matcha-TTS logo", height=50, width=50, scale=1, show_label=False)
|
|
176
|
+
html = '<br><iframe width="560" height="315" src="https://www.youtube.com/embed/xmvJkz3bqw0?si=jN7ILyDsbPwJCGoa" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
|
|
177
|
+
gr.HTML(html)
|
|
178
|
+
|
|
179
|
+
with gr.Box():
|
|
180
|
+
radio_options = list(RADIO_OPTIONS.keys())
|
|
181
|
+
model_type = gr.Radio(
|
|
182
|
+
radio_options, value=radio_options[0], label="Choose a Model", interactive=True, container=False
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
with gr.Row():
|
|
186
|
+
gr.Markdown("# Text Input")
|
|
187
|
+
with gr.Row():
|
|
188
|
+
text = gr.Textbox(value="", lines=2, label="Text to synthesise", scale=3)
|
|
189
|
+
spk_slider = gr.Slider(
|
|
190
|
+
minimum=0, maximum=107, step=1, value=args.spk, label="Speaker ID", interactive=True, scale=1
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
with gr.Row():
|
|
194
|
+
gr.Markdown("### Hyper parameters")
|
|
195
|
+
with gr.Row():
|
|
196
|
+
n_timesteps = gr.Slider(
|
|
197
|
+
label="Number of ODE steps",
|
|
198
|
+
minimum=1,
|
|
199
|
+
maximum=100,
|
|
200
|
+
step=1,
|
|
201
|
+
value=10,
|
|
202
|
+
interactive=True,
|
|
203
|
+
)
|
|
204
|
+
length_scale = gr.Slider(
|
|
205
|
+
label="Length scale (Speaking rate)",
|
|
206
|
+
minimum=0.5,
|
|
207
|
+
maximum=1.5,
|
|
208
|
+
step=0.05,
|
|
209
|
+
value=1.0,
|
|
210
|
+
interactive=True,
|
|
211
|
+
)
|
|
212
|
+
mel_temp = gr.Slider(
|
|
213
|
+
label="Sampling temperature",
|
|
214
|
+
minimum=0.00,
|
|
215
|
+
maximum=2.001,
|
|
216
|
+
step=0.16675,
|
|
217
|
+
value=0.667,
|
|
218
|
+
interactive=True,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
synth_btn = gr.Button("Synthesise")
|
|
222
|
+
|
|
223
|
+
with gr.Box():
|
|
224
|
+
with gr.Row():
|
|
225
|
+
gr.Markdown("### Phonetised text")
|
|
226
|
+
phonetised_text = gr.Textbox(interactive=False, scale=10, label="Phonetised text")
|
|
227
|
+
|
|
228
|
+
with gr.Box():
|
|
229
|
+
with gr.Row():
|
|
230
|
+
mel_spectrogram = gr.Image(interactive=False, label="mel spectrogram")
|
|
231
|
+
|
|
232
|
+
# with gr.Row():
|
|
233
|
+
audio = gr.Audio(interactive=False, label="Audio")
|
|
234
|
+
|
|
235
|
+
with gr.Row(visible=False) as example_row_lj_speech:
|
|
236
|
+
examples = gr.Examples( # pylint: disable=unused-variable
|
|
237
|
+
examples=[
|
|
238
|
+
[
|
|
239
|
+
"We propose Matcha-TTS, a new approach to non-autoregressive neural TTS, that uses conditional flow matching (similar to rectified flows) to speed up O D E-based speech synthesis.",
|
|
240
|
+
50,
|
|
241
|
+
0.677,
|
|
242
|
+
0.95,
|
|
243
|
+
],
|
|
244
|
+
[
|
|
245
|
+
"The Secret Service believed that it was very doubtful that any President would ride regularly in a vehicle with a fixed top, even though transparent.",
|
|
246
|
+
2,
|
|
247
|
+
0.677,
|
|
248
|
+
0.95,
|
|
249
|
+
],
|
|
250
|
+
[
|
|
251
|
+
"The Secret Service believed that it was very doubtful that any President would ride regularly in a vehicle with a fixed top, even though transparent.",
|
|
252
|
+
4,
|
|
253
|
+
0.677,
|
|
254
|
+
0.95,
|
|
255
|
+
],
|
|
256
|
+
[
|
|
257
|
+
"The Secret Service believed that it was very doubtful that any President would ride regularly in a vehicle with a fixed top, even though transparent.",
|
|
258
|
+
10,
|
|
259
|
+
0.677,
|
|
260
|
+
0.95,
|
|
261
|
+
],
|
|
262
|
+
[
|
|
263
|
+
"The Secret Service believed that it was very doubtful that any President would ride regularly in a vehicle with a fixed top, even though transparent.",
|
|
264
|
+
50,
|
|
265
|
+
0.677,
|
|
266
|
+
0.95,
|
|
267
|
+
],
|
|
268
|
+
[
|
|
269
|
+
"The narrative of these events is based largely on the recollections of the participants.",
|
|
270
|
+
10,
|
|
271
|
+
0.677,
|
|
272
|
+
0.95,
|
|
273
|
+
],
|
|
274
|
+
[
|
|
275
|
+
"The jury did not believe him, and the verdict was for the defendants.",
|
|
276
|
+
10,
|
|
277
|
+
0.677,
|
|
278
|
+
0.95,
|
|
279
|
+
],
|
|
280
|
+
],
|
|
281
|
+
fn=ljspeech_example_cacher,
|
|
282
|
+
inputs=[text, n_timesteps, mel_temp, length_scale],
|
|
283
|
+
outputs=[phonetised_text, audio, mel_spectrogram],
|
|
284
|
+
cache_examples=True,
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
with gr.Row() as example_row_multispeaker:
|
|
288
|
+
multi_speaker_examples = gr.Examples( # pylint: disable=unused-variable
|
|
289
|
+
examples=[
|
|
290
|
+
[
|
|
291
|
+
"Hello everyone! I am speaker 0 and I am here to tell you that Matcha-TTS is amazing!",
|
|
292
|
+
10,
|
|
293
|
+
0.677,
|
|
294
|
+
0.85,
|
|
295
|
+
0,
|
|
296
|
+
],
|
|
297
|
+
[
|
|
298
|
+
"Hello everyone! I am speaker 16 and I am here to tell you that Matcha-TTS is amazing!",
|
|
299
|
+
10,
|
|
300
|
+
0.677,
|
|
301
|
+
0.85,
|
|
302
|
+
16,
|
|
303
|
+
],
|
|
304
|
+
[
|
|
305
|
+
"Hello everyone! I am speaker 44 and I am here to tell you that Matcha-TTS is amazing!",
|
|
306
|
+
50,
|
|
307
|
+
0.677,
|
|
308
|
+
0.85,
|
|
309
|
+
44,
|
|
310
|
+
],
|
|
311
|
+
[
|
|
312
|
+
"Hello everyone! I am speaker 45 and I am here to tell you that Matcha-TTS is amazing!",
|
|
313
|
+
50,
|
|
314
|
+
0.677,
|
|
315
|
+
0.85,
|
|
316
|
+
45,
|
|
317
|
+
],
|
|
318
|
+
[
|
|
319
|
+
"Hello everyone! I am speaker 58 and I am here to tell you that Matcha-TTS is amazing!",
|
|
320
|
+
4,
|
|
321
|
+
0.677,
|
|
322
|
+
0.85,
|
|
323
|
+
58,
|
|
324
|
+
],
|
|
325
|
+
],
|
|
326
|
+
fn=multispeaker_example_cacher,
|
|
327
|
+
inputs=[text, n_timesteps, mel_temp, length_scale, spk_slider],
|
|
328
|
+
outputs=[phonetised_text, audio, mel_spectrogram],
|
|
329
|
+
cache_examples=True,
|
|
330
|
+
label="Multi Speaker Examples",
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
model_type.change(lambda x: gr.update(interactive=False), inputs=[synth_btn], outputs=[synth_btn]).then(
|
|
334
|
+
load_model_ui,
|
|
335
|
+
inputs=[model_type, text],
|
|
336
|
+
outputs=[text, synth_btn, spk_slider, example_row_lj_speech, example_row_multispeaker, length_scale],
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
synth_btn.click(
|
|
340
|
+
fn=process_text_gradio,
|
|
341
|
+
inputs=[
|
|
342
|
+
text,
|
|
343
|
+
],
|
|
344
|
+
outputs=[phonetised_text, processed_text, processed_text_len],
|
|
345
|
+
api_name="matcha_tts",
|
|
346
|
+
queue=True,
|
|
347
|
+
).then(
|
|
348
|
+
fn=synthesise_mel,
|
|
349
|
+
inputs=[processed_text, processed_text_len, n_timesteps, mel_temp, length_scale, spk_slider],
|
|
350
|
+
outputs=[audio, mel_spectrogram],
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
demo.queue().launch(share=True)
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
if __name__ == "__main__":
|
|
357
|
+
main()
|