Katock commited on
Commit
aef0422
·
1 Parent(s): 2be4936

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -16
app.py CHANGED
@@ -18,7 +18,6 @@ logging.getLogger('matplotlib').setLevel(logging.WARNING)
18
 
19
  limitation = os.getenv("SYSTEM") == "spaces" # limit audio length in huggingface spaces
20
 
21
-
22
  audio_postprocess_ori = gr.Audio.postprocess
23
 
24
 
@@ -43,20 +42,17 @@ def create_vc_fn(model, spk):
43
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
44
  if len(audio.shape) > 1:
45
  audio = librosa.to_mono(audio.transpose(1, 0))
46
- if sampling_rate != 16000:
47
- audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
48
 
49
  raw_audio_path = io.BytesIO()
50
  soundfile.write(raw_audio_path, audio, sampling_rate, format="wav")
51
  raw_audio_path.seek(0)
52
- # out_audio, _, _ = model.infer(raw_path=raw_audio_path,
53
- # speaker=spk,
54
- # tran=vc_transform,
55
- # f0_predictor=f0p,
56
- # auto_predict_f0=auto_f0)
57
 
58
- # return "Success", (44100, out_audio.cpu().numpy())
59
- return 'test', (44100, audio)
60
 
61
  return vc_fn
62
 
@@ -91,14 +87,13 @@ if __name__ == '__main__':
91
  )
92
  with gr.Column():
93
  vc_input = gr.Audio(label="输入干声" + ' (小于 20 秒)' if limitation else '')
94
- vc_transform = gr.Number(label="音高调整(支持正负半音,12为一个八度)", value=0)
95
- auto_f0 = gr.Checkbox(label="自动音高预测(正常说话可选)", value=False)
96
- f0_predictor = gr.Radio(label="f0预测器(对电音大小有影响,可以都试试)",
97
  choices=['crepe', 'harvest', 'dio', 'pm'], value='crepe')
98
  vc_submit = gr.Button("生成", variant="primary")
99
 
100
  with gr.Column():
101
- vc_output1 = gr.Textbox(label="输出信息")
102
- vc_output2 = gr.Audio(label="输出音频")
103
- vc_submit.click(vc_fn, [vc_input, vc_transform, auto_f0, f0_predictor], [vc_output1, vc_output2])
104
  app.queue(concurrency_count=1, api_open=args.api).launch(share=args.share)
 
18
 
19
  limitation = os.getenv("SYSTEM") == "spaces" # limit audio length in huggingface spaces
20
 
 
21
  audio_postprocess_ori = gr.Audio.postprocess
22
 
23
 
 
42
  audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
43
  if len(audio.shape) > 1:
44
  audio = librosa.to_mono(audio.transpose(1, 0))
 
 
45
 
46
  raw_audio_path = io.BytesIO()
47
  soundfile.write(raw_audio_path, audio, sampling_rate, format="wav")
48
  raw_audio_path.seek(0)
49
+ out_audio, _, _ = model.infer(raw_path=raw_audio_path,
50
+ speaker=spk,
51
+ tran=vc_transform,
52
+ f0_predictor=f0p,
53
+ auto_predict_f0=auto_f0)
54
 
55
+ return 44100, out_audio.cpu().numpy()
 
56
 
57
  return vc_fn
58
 
 
87
  )
88
  with gr.Column():
89
  vc_input = gr.Audio(label="输入干声" + ' (小于 20 秒)' if limitation else '')
90
+ vc_transform = gr.Number(label="音高调整 (支持正负半音,12为一个八度)", value=0)
91
+ auto_f0 = gr.Checkbox(label="自动音高预测 (正常说话可选)", value=False)
92
+ f0_predictor = gr.Radio(label="f0预测器 (对电音有影响)",
93
  choices=['crepe', 'harvest', 'dio', 'pm'], value='crepe')
94
  vc_submit = gr.Button("生成", variant="primary")
95
 
96
  with gr.Column():
97
+ vc_output = gr.Audio(label="输出音频")
98
+ vc_submit.click(vc_fn, [vc_input, vc_transform, auto_f0, f0_predictor], vc_output)
 
99
  app.queue(concurrency_count=1, api_open=args.api).launch(share=args.share)