Spaces:
Running
Running
ORI-Muchim
commited on
Commit
•
9db4439
1
Parent(s):
ead8262
Update app.py
Browse files
app.py
CHANGED
@@ -25,21 +25,24 @@ def get_text(text, hps, is_phoneme):
|
|
25 |
|
26 |
|
27 |
def create_tts_fn(model, hps, speaker_ids):
|
28 |
-
def tts_fn(text, speaker, speed,
|
29 |
if limitation:
|
30 |
-
text_len = len(
|
31 |
-
max_len =
|
32 |
-
if
|
33 |
max_len *= 3
|
|
|
|
|
|
|
34 |
if text_len > max_len:
|
35 |
return "Error: Text is too long", None
|
36 |
|
37 |
speaker_id = speaker_ids[speaker]
|
38 |
-
stn_tst = get_text(text, hps,
|
39 |
with no_grad():
|
40 |
-
x_tst = stn_tst.unsqueeze(0)
|
41 |
-
x_tst_lengths = LongTensor([stn_tst.size(0)])
|
42 |
-
sid = LongTensor([speaker_id])
|
43 |
audio = model.infer(x_tst, x_tst_lengths, sid=sid, noise_scale=.667, noise_scale_w=0.8,
|
44 |
length_scale=1.0 / speed)[0][0, 0].data.cpu().float().numpy()
|
45 |
del stn_tst, x_tst, x_tst_lengths, sid
|
|
|
25 |
|
26 |
|
27 |
def create_tts_fn(model, hps, speaker_ids):
|
28 |
+
def tts_fn(text, speaker, speed, is_phoneme):
|
29 |
if limitation:
|
30 |
+
text_len = len(text)
|
31 |
+
max_len = 100
|
32 |
+
if is_phoneme:
|
33 |
max_len *= 3
|
34 |
+
else:
|
35 |
+
if len(hps.data.text_cleaners) > 0 and hps.data.text_cleaners[0] == "zh_ja_mixture_cleaners":
|
36 |
+
text_len = len(re.sub("(\[ZH\]|\[JA\])", "", text))
|
37 |
if text_len > max_len:
|
38 |
return "Error: Text is too long", None
|
39 |
|
40 |
speaker_id = speaker_ids[speaker]
|
41 |
+
stn_tst = get_text(text, hps, is_phoneme)
|
42 |
with no_grad():
|
43 |
+
x_tst = stn_tst.unsqueeze(0)
|
44 |
+
x_tst_lengths = LongTensor([stn_tst.size(0)])
|
45 |
+
sid = LongTensor([speaker_id])
|
46 |
audio = model.infer(x_tst, x_tst_lengths, sid=sid, noise_scale=.667, noise_scale_w=0.8,
|
47 |
length_scale=1.0 / speed)[0][0, 0].data.cpu().float().numpy()
|
48 |
del stn_tst, x_tst, x_tst_lengths, sid
|