hzrr commited on
Commit
9d44aa3
·
1 Parent(s): 63321a7
Files changed (1) hide show
  1. app.py +25 -3
app.py CHANGED
@@ -46,7 +46,8 @@ def load_model(config_path, pth_path):
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)
@@ -82,11 +83,32 @@ with app:
82
  with gr.Row():
83
  tts_input1 = gr.TextArea(
84
  label="请输入文本(仅支持日语)", value="こんにちは,世界!")
85
- c_name = gr.Radio([character_dict.keys()])
 
 
86
  tts_submit = gr.Button("用文本合成", variant="primary")
87
  tts_output2 = gr.Audio(label="Output")
88
  # model_submit.click(load_model, [config_path, pth_path])
89
- tts_submit.click(infer, [character_dict[c_name], tts_input1], [tts_output2])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  gr.HTML("""
91
  <div style="text-align:center">
92
  <h4 class="h-sign" style="font-size: 12px;">
 
46
  print(f"{pth_path}加载成功!")
47
 
48
  def infer(c_id, text):
49
+ if c_id not in list(range[1, 14]):
50
+ raise gr.Error("角色id超出范围!")
51
  stn_tst = get_text(text, hps)
52
  with torch.no_grad():
53
  x_tst = stn_tst.to(dev).unsqueeze(0)
 
83
  with gr.Row():
84
  tts_input1 = gr.TextArea(
85
  label="请输入文本(仅支持日语)", value="こんにちは,世界!")
86
+ tts_input2 = gr.TextArea(
87
+ label="请输入角色id(参考文档或者页面下方表格)")
88
+
89
  tts_submit = gr.Button("用文本合成", variant="primary")
90
  tts_output2 = gr.Audio(label="Output")
91
  # model_submit.click(load_model, [config_path, pth_path])
92
+ tts_submit.click(infer, [tts_input2, tts_input1], [tts_output2])
93
+ gr.Markdown(
94
+ """
95
+ | id | 角色名 |
96
+ |--|--|
97
+ | 1 | 夜刀神十香 |
98
+ | 2 | 鸢一折纸 |
99
+ | 3 | 时崎狂三 |
100
+ | 4 | 冰芽川四糸乃 |
101
+ | 5 | 五河琴里 |
102
+ | 6 | 八舞夕弦 |
103
+ | 7 | 八舞耶俱矢 |
104
+ | 8 | 诱宵美九 |
105
+ | 9 | 园神凛祢 |
106
+ | 10 | 园神凛绪 |
107
+ | 11 | 或守鞠亚 |
108
+ | 12 | 或守鞠奈 |
109
+ | 13 | 崇宫真那 |
110
+ """
111
+ )
112
  gr.HTML("""
113
  <div style="text-align:center">
114
  <h4 class="h-sign" style="font-size: 12px;">