Spaces:
Build error
Build error
...
Browse files
app.py
CHANGED
@@ -46,10 +46,7 @@ def load_model(config_path, pth_path):
|
|
46 |
print(f"{pth_path}加载成功!")
|
47 |
|
48 |
def infer(c_id, text):
|
49 |
-
|
50 |
-
raise gr.Error("角色id超出范围!")"""
|
51 |
-
with open("tmp.txt", "w") as fp:
|
52 |
-
fp.write(c_id)
|
53 |
stn_tst = get_text(text, hps)
|
54 |
with torch.no_grad():
|
55 |
x_tst = stn_tst.to(dev).unsqueeze(0)
|
@@ -83,17 +80,18 @@ app = gr.Blocks()
|
|
83 |
with app:
|
84 |
with gr.Tabs():
|
85 |
with gr.Row():
|
86 |
-
|
87 |
label="请输入文本(仅支持日语)", value="こんにちは,世界!")
|
88 |
with gr.Row():
|
89 |
-
|
90 |
label="请输入角色id(参考文档或者页面下方表格)")
|
91 |
with gr.Row():
|
92 |
tts_submit = gr.Button("用文本合成", variant="primary")
|
93 |
with gr.Row():
|
94 |
-
|
95 |
# model_submit.click(load_model, [config_path, pth_path])
|
96 |
-
tts_submit.click(infer, [
|
|
|
97 |
gr.Markdown(
|
98 |
"""
|
99 |
| id | 角色名 |
|
|
|
46 |
print(f"{pth_path}加载成功!")
|
47 |
|
48 |
def infer(c_id, text):
|
49 |
+
|
|
|
|
|
|
|
50 |
stn_tst = get_text(text, hps)
|
51 |
with torch.no_grad():
|
52 |
x_tst = stn_tst.to(dev).unsqueeze(0)
|
|
|
80 |
with app:
|
81 |
with gr.Tabs():
|
82 |
with gr.Row():
|
83 |
+
text = gr.TextArea(
|
84 |
label="请输入文本(仅支持日语)", value="こんにちは,世界!")
|
85 |
with gr.Row():
|
86 |
+
radio = gr.Radio(
|
87 |
label="请输入角色id(参考文档或者页面下方表格)")
|
88 |
with gr.Row():
|
89 |
tts_submit = gr.Button("用文本合成", variant="primary")
|
90 |
with gr.Row():
|
91 |
+
tts_output = gr.Audio(label="Output")
|
92 |
# model_submit.click(load_model, [config_path, pth_path])
|
93 |
+
tts_submit.click(infer, [radio, text], [tts_output])
|
94 |
+
radio.change(infer, [radio, text], [tts_output])
|
95 |
gr.Markdown(
|
96 |
"""
|
97 |
| id | 角色名 |
|
tmp.txt
DELETED
File without changes
|