Plachta commited on
Commit
9172fd2
1 Parent(s): e0866ea

更新了参数调整功能

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -34,7 +34,7 @@ net_g = SynthesizerTrn(
34
  **hps.model)
35
  _ = net_g.eval()
36
 
37
- _ = utils.load_checkpoint("pretrained_models/G_1153000.pth", net_g, None)
38
 
39
  title = "Umamusume voice synthesizer \n 赛马娘语音合成器"
40
  description = """
@@ -49,7 +49,7 @@ article = """
49
  """
50
 
51
 
52
- def infer(text, character, language):
53
  if language == '日本語':
54
  pass
55
  elif language == '简体中文':
@@ -62,7 +62,7 @@ def infer(text, character, language):
62
  x_tst = stn_tst.unsqueeze(0)
63
  x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
64
  sid = torch.LongTensor([char_id])
65
- audio = net_g.infer(x_tst, x_tst_lengths, sid=sid, noise_scale=0.667, noise_scale_w=0.8, length_scale=1)[0][0,0].data.cpu().float().numpy()
66
  return (text,(22050, audio))
67
 
68
  # We instantiate the Textbox class
@@ -90,16 +90,16 @@ char_dropdown = gr.Dropdown(['0:特别周','1:无声铃鹿','2:东海帝王','3:
90
  '76:也文摄辉','77:吉兆','78:谷野美酒','79:第一红宝石',
91
  '80:真弓快车','81:骏川手纲','82:凯斯奇迹','83:小林历奇',
92
  '84:北港火山','85:奇锐骏','86:秋川理事长'])
93
- language_dropdown = gr.Dropdown(['日本語','简体中文','English'])
94
- examples = [['お疲れ様です,トレーナーさん。', '1:无声铃鹿', '日本語'],
95
- ['張り切っていこう!', '67:北部玄驹', '日本語'],
96
- ['何でこんなに慣れでんのよ,私のほが先に好きだっだのに。', '10:草上飞','日本語'],
97
- ['授業中に出しだら,学校生活終わるですわ。', '12:目白麦昆','日本語'],
98
- ['お帰りなさい,お兄様!', '29:米浴','日本語'],
99
- ['私の処女をもらっでください!', '29:米浴','日本語']]
100
 
101
  duration_slider = gr.Slider(minimum=0.1, maximum=5, value=1, step=0.1, label='时长 Duration')
102
  noise_scale_slider = gr.Slider(minimum=0.1, maximum=5, value=0.667, step=0.001, label='噪声比例 noise_scale')
103
  noise_scale_w_slider = gr.Slider(minimum=0.1, maximum=5, value=0.8, step=0.1, label='噪声偏差 noise_scale_w')
104
 
105
- gr.Interface(fn=infer, inputs=[textbox, char_dropdown, language_dropdown], outputs=["text","audio"],title=title, description=description, article=article, examples=examples).launch()
 
34
  **hps.model)
35
  _ = net_g.eval()
36
 
37
+ _ = utils.load_checkpoint("pretrained_models/uma_1153000.pth", net_g, None)
38
 
39
  title = "Umamusume voice synthesizer \n 赛马娘语音合成器"
40
  description = """
 
49
  """
50
 
51
 
52
+ def infer(text, character, language, duration, noise_scale, noise_scale_w):
53
  if language == '日本語':
54
  pass
55
  elif language == '简体中文':
 
62
  x_tst = stn_tst.unsqueeze(0)
63
  x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
64
  sid = torch.LongTensor([char_id])
65
+ audio = net_g.infer(x_tst, x_tst_lengths, sid=sid, noise_scale=noise_scale, noise_scale_w=noise_scale_w, length_scale=duration)[0][0,0].data.cpu().float().numpy()
66
  return (text,(22050, audio))
67
 
68
  # We instantiate the Textbox class
 
90
  '76:也文摄辉','77:吉兆','78:谷野美酒','79:第一红宝石',
91
  '80:真弓快车','81:骏川手纲','82:凯斯奇迹','83:小林历奇',
92
  '84:北港火山','85:奇锐骏','86:秋川理事长'])
93
+ language_dropdown = gr.Dropdown(['日本語','简体中文','English', 1, 0.667, 0.8])
94
+ examples = [['お疲れ様です,トレーナーさん。', '1:无声铃鹿', '日本語', 1, 0.667, 0.8],
95
+ ['張り切っていこう!', '67:北部玄驹', '日本語', 1, 0.667, 0.8],
96
+ ['何でこんなに慣れでんのよ,私のほが先に好きだっだのに。', '10:草上飞','日本語', 1, 0.667, 0.8],
97
+ ['授業中に出しだら,学校生活終わるですわ。', '12:目白麦昆','日本語', 1, 0.667, 0.8],
98
+ ['お帰りなさい,お兄様!', '29:米浴','日本語', 1, 0.667, 0.8],
99
+ ['私の処女をもらっでください!', '29:米浴','日本語', 1, 0.667, 0.8]]
100
 
101
  duration_slider = gr.Slider(minimum=0.1, maximum=5, value=1, step=0.1, label='时长 Duration')
102
  noise_scale_slider = gr.Slider(minimum=0.1, maximum=5, value=0.667, step=0.001, label='噪声比例 noise_scale')
103
  noise_scale_w_slider = gr.Slider(minimum=0.1, maximum=5, value=0.8, step=0.1, label='噪声偏差 noise_scale_w')
104
 
105
+ gr.Interface(fn=infer, inputs=[textbox, char_dropdown, language_dropdown, duration_slider, noise_scale_slider, noise_scale_w_slider,], outputs=["text","audio"],title=title, description=description, article=article, examples=examples).launch()