Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -76,6 +76,16 @@ def tts_fn(text):
|
|
76 |
x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
|
77 |
audio = net_g.infer(x_tst, x_tst_lengths, noise_scale=.667, noise_scale_w=0.8, length_scale=1)[0][0,0].data.float().numpy()
|
78 |
return "Success", (hps.data.sampling_rate, audio)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
|
81 |
if __name__ == '__main__':
|
@@ -84,11 +94,20 @@ if __name__ == '__main__':
|
|
84 |
app = gr.Blocks()
|
85 |
|
86 |
with app:
|
87 |
-
with gr.
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
tts_submit.click(tts_fn, tts_input1, [tts_output1, tts_output2])
|
93 |
-
|
|
|
94 |
app.launch()
|
|
|
76 |
x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
|
77 |
audio = net_g.infer(x_tst, x_tst_lengths, noise_scale=.667, noise_scale_w=0.8, length_scale=1)[0][0,0].data.float().numpy()
|
78 |
return "Success", (hps.data.sampling_rate, audio)
|
79 |
+
|
80 |
+
def jtts_fn(text):
|
81 |
+
if len(text) > 150:
|
82 |
+
return "Error: Text is too long", None
|
83 |
+
stn_tst = get_text(japanese_phrase_cleaners(text), hps)
|
84 |
+
with torch.no_grad():
|
85 |
+
x_tst = stn_tst.unsqueeze(0)
|
86 |
+
x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
|
87 |
+
audio = net_g.infer(x_tst, x_tst_lengths, noise_scale=.667, noise_scale_w=0.8, length_scale=1)[0][0,0].data.float().numpy()
|
88 |
+
return "Success", (hps.data.sampling_rate, audio)
|
89 |
|
90 |
|
91 |
if __name__ == '__main__':
|
|
|
94 |
app = gr.Blocks()
|
95 |
|
96 |
with app:
|
97 |
+
with gr.Tabs():
|
98 |
+
with gr.TabItem("TTS"):
|
99 |
+
with gr.Column():
|
100 |
+
tts_input1 = gr.TextArea(label="Text (150 words limitation)", value="mutekino teioodeNsetsu, kokokara sUtaatodacl!")
|
101 |
+
tts_submit = gr.Button("Generate", variant="primary")
|
102 |
+
tts_output1 = gr.Textbox(label="Output Message")
|
103 |
+
tts_output2 = gr.Audio(label="Output Audio")
|
104 |
+
with gr.TabItem("JTTS"):
|
105 |
+
with gr.Column():
|
106 |
+
jtts_input1 = gr.TextArea(label="Text (150 words limitation)", value="無敵のテイオー伝説、ここからスタートだっ!")
|
107 |
+
jtts_submit = gr.Button("Generate", variant="primary")
|
108 |
+
jtts_output1 = gr.Textbox(label="Output Message")
|
109 |
+
jtts_output2 = gr.Audio(label="Output Audio")
|
110 |
tts_submit.click(tts_fn, tts_input1, [tts_output1, tts_output2])
|
111 |
+
jtts_submit.click(jtts_fn, jtts_input1, [jtts_output1, jtts_output2])
|
112 |
+
|
113 |
app.launch()
|