Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,14 +26,14 @@ def init_models(hparams):
|
|
26 |
vocoder_model.load_state_dict(checkpoint['model_g'])
|
27 |
vocoder_model = vocoder_model.to('cuda')
|
28 |
vocoder_model.eval(inference=False)
|
29 |
-
|
30 |
-
gst_head_scores = np.array([0.5, 0.15, 0.35]) # originally ([0.5, 0.15, 0.35])
|
31 |
-
gst_scores = torch.from_numpy(gst_head_scores).cuda().float()
|
32 |
|
33 |
def synthesize(text):
|
34 |
sequence = np.array(text_to_sequence(text, ['english_cleaners']))[None, :]
|
35 |
sequence = torch.from_numpy(sequence).to(device='cuda', dtype=torch.int64)
|
36 |
|
|
|
|
|
|
|
37 |
mel_outputs, mel_outputs_postnet, _, alignments = model.inference(sequence, gst_scores)
|
38 |
|
39 |
# mel2wav inference:
|
@@ -42,11 +42,10 @@ def synthesize(text):
|
|
42 |
|
43 |
audio_numpy = audio.data.cpu().detach().numpy()
|
44 |
|
45 |
-
return
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
iface.launch()
|
52 |
|
|
|
26 |
vocoder_model.load_state_dict(checkpoint['model_g'])
|
27 |
vocoder_model = vocoder_model.to('cuda')
|
28 |
vocoder_model.eval(inference=False)
|
|
|
|
|
|
|
29 |
|
30 |
def synthesize(text):
|
31 |
sequence = np.array(text_to_sequence(text, ['english_cleaners']))[None, :]
|
32 |
sequence = torch.from_numpy(sequence).to(device='cuda', dtype=torch.int64)
|
33 |
|
34 |
+
gst_head_scores = np.array([0.5, 0.15, 0.35]) # originally ([0.5, 0.15, 0.35])
|
35 |
+
gst_scores = torch.from_numpy(gst_head_scores).cuda().float()
|
36 |
+
|
37 |
mel_outputs, mel_outputs_postnet, _, alignments = model.inference(sequence, gst_scores)
|
38 |
|
39 |
# mel2wav inference:
|
|
|
42 |
|
43 |
audio_numpy = audio.data.cpu().detach().numpy()
|
44 |
|
45 |
+
return (22050, audio_numpy)
|
46 |
|
47 |
+
|
48 |
+
init_models(hparams)
|
49 |
+
iface = gr.Interface(fn=synthesize, inputs="text", outputs=[gr.Audio(label="Generated Speech", type="numpy"),])
|
50 |
+
iface.launch()
|
|
|
51 |
|