innnky commited on
Commit
88cb6ea
1 Parent(s): 68e3b88
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -39,6 +39,7 @@ def get_text(text, hps):
39
  print(text_norm.shape)
40
  return text_norm
41
 
 
42
 
43
  hps_ms = utils.get_hparams_from_file("configs/nyarumul.json")
44
  net_g_ms = SynthesizerTrn(
@@ -62,7 +63,7 @@ def vc_fn(sid, input_audio,vc_transform):
62
  # print(audio.shape,sampling_rate)
63
  duration = audio.shape[0] / sampling_rate
64
  if duration > 45:
65
- return "Error: Audio is too long", None
66
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
67
  if len(audio.shape) > 1:
68
  audio = librosa.to_mono(audio.transpose(1, 0))
@@ -85,7 +86,8 @@ def vc_fn(sid, input_audio,vc_transform):
85
  x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
86
  audio = net_g_ms.infer(x_tst, x_tst_lengths, pitch=pitch,sid=sid, noise_scale=0.4,
87
  noise_scale_w=0.1, length_scale=1)[0][0, 0].data.float().numpy()
88
-
 
89
  return "Success", (hps_ms.data.sampling_rate, audio)
90
 
91
 
 
39
  print(text_norm.shape)
40
  return text_norm
41
 
42
+ convert_cnt = [0]
43
 
44
  hps_ms = utils.get_hparams_from_file("configs/nyarumul.json")
45
  net_g_ms = SynthesizerTrn(
 
63
  # print(audio.shape,sampling_rate)
64
  duration = audio.shape[0] / sampling_rate
65
  if duration > 45:
66
+ return "请上传小于45s的音频,需要转换长音频请使用colab", None
67
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
68
  if len(audio.shape) > 1:
69
  audio = librosa.to_mono(audio.transpose(1, 0))
 
86
  x_tst_lengths = torch.LongTensor([stn_tst.size(0)])
87
  audio = net_g_ms.infer(x_tst, x_tst_lengths, pitch=pitch,sid=sid, noise_scale=0.4,
88
  noise_scale_w=0.1, length_scale=1)[0][0, 0].data.float().numpy()
89
+ convert_cnt[0] += 1
90
+ print(convert_cnt[0])
91
  return "Success", (hps_ms.data.sampling_rate, audio)
92
 
93