Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ def get_text(text, hps):
|
|
25 |
text_norm = torch.LongTensor(text_norm)
|
26 |
return text_norm
|
27 |
|
28 |
-
hps = utils.get_hparams_from_file("
|
29 |
|
30 |
net_g = SynthesizerTrn(
|
31 |
len(symbols),
|
@@ -35,5 +35,34 @@ net_g = SynthesizerTrn(
|
|
35 |
**hps.model)
|
36 |
_ = net_g.eval()
|
37 |
|
38 |
-
_ = utils.load_checkpoint("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
|
|
25 |
text_norm = torch.LongTensor(text_norm)
|
26 |
return text_norm
|
27 |
|
28 |
+
hps = utils.get_hparams_from_file("configs/vctk_base.json")
|
29 |
|
30 |
net_g = SynthesizerTrn(
|
31 |
len(symbols),
|
|
|
35 |
**hps.model)
|
36 |
_ = net_g.eval()
|
37 |
|
38 |
+
_ = utils.load_checkpoint("fr_wa_finetuned_pho/G_125000.pth", net_g, None)
|
39 |
+
|
40 |
+
|
41 |
+
def tts(text):
|
42 |
+
if len(text) > 150:
|
43 |
+
return "Error: Text is too long", None
|
44 |
+
sid = torch.LongTensor([1]) # speaker identity
|
45 |
+
stn_tst = get_text(text, hps_ms)
|
46 |
+
|
47 |
+
with torch.no_grad():
|
48 |
+
x_tst = stn_tst.unsqueeze(0)
|
49 |
+
x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
|
50 |
+
# print(stn_tst.size())
|
51 |
+
audio = net_g_ms.infer(x_tst, x_tst_lengths, sid=sid, noise_scale=.667, noise_scale_w=0.8, length_scale=1)[0][
|
52 |
+
0, 0].data.float().numpy()
|
53 |
+
return "Success", (hps.data.sampling_rate, audio)
|
54 |
+
|
55 |
+
app = gr.Blocks()
|
56 |
+
with app:
|
57 |
+
with gr.Tabs():
|
58 |
+
with gr.TabItem("Basic"):
|
59 |
+
tts_input1 = gr.TextArea(label="Text in Japanese (150 words limitation)", value="こんにちは。")
|
60 |
+
# tts_input2 = gr.Dropdown(label="Speaker", choices=hps.speakers, type="index", value=hps.speakers[0])
|
61 |
+
tts_submit = gr.Button("Generate", variant="primary")
|
62 |
+
tts_output1 = gr.Textbox(label="Message")
|
63 |
+
tts_output2 = gr.Audio(label="Output")
|
64 |
+
tts_submit.click(tts, [tts_input1], [tts_output1, tts_output2])
|
65 |
+
|
66 |
+
app.launch()
|
67 |
+
|
68 |
|