Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -22,8 +22,8 @@ def vc_fn(sid, input_audio, vc_transform, auto_f0,cluster_ratio, noise_scale):
|
|
22 |
sampling_rate, audio = input_audio
|
23 |
# print(audio.shape,sampling_rate)
|
24 |
duration = audio.shape[0] / sampling_rate
|
25 |
-
if duration >
|
26 |
-
return "请上传小于
|
27 |
audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
|
28 |
if len(audio.shape) > 1:
|
29 |
audio = librosa.to_mono(audio.transpose(1, 0))
|
@@ -33,12 +33,8 @@ def vc_fn(sid, input_audio, vc_transform, auto_f0,cluster_ratio, noise_scale):
|
|
33 |
out_wav_path = "temp.wav"
|
34 |
soundfile.write(out_wav_path, audio, 16000, format="wav")
|
35 |
print( cluster_ratio, auto_f0, noise_scale)
|
36 |
-
|
37 |
-
|
38 |
-
auto_predict_f0=auto_f0,
|
39 |
-
noice_scale=noise_scale
|
40 |
-
)
|
41 |
-
return "转换成功", (44100, out_audio.numpy())
|
42 |
|
43 |
|
44 |
app = gr.Blocks()
|
@@ -62,7 +58,7 @@ with app:
|
|
62 |
""")
|
63 |
spks = list(model.spk2id.keys())
|
64 |
sid = gr.Dropdown(label="音色", choices=["XT4.0"], value="XT4.0")
|
65 |
-
vc_input3 = gr.Audio(label="上传音频(长度建议小于
|
66 |
vc_transform = gr.Number(label="变调(整数,可以正负,半音数量,升高八度就是12)", value=0)
|
67 |
cluster_ratio = gr.Number(label="聚类模型混合比例,0-1之间,默认为0不启用聚类,能提升音色相似度,但会导致咬字下降(如果使用建议0.5左右)", value=0)
|
68 |
auto_f0 = gr.Checkbox(label="自动f0预测,配合聚类模型f0预测效果更好,会导致变调功能失效(仅限转换语音,歌声不要勾选此项会究极跑调)", value=False)
|
|
|
22 |
sampling_rate, audio = input_audio
|
23 |
# print(audio.shape,sampling_rate)
|
24 |
duration = audio.shape[0] / sampling_rate
|
25 |
+
if duration > 90:
|
26 |
+
return "请上传小于90s的音频,需要转换长音频请本地进行转换", None
|
27 |
audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
|
28 |
if len(audio.shape) > 1:
|
29 |
audio = librosa.to_mono(audio.transpose(1, 0))
|
|
|
33 |
out_wav_path = "temp.wav"
|
34 |
soundfile.write(out_wav_path, audio, 16000, format="wav")
|
35 |
print( cluster_ratio, auto_f0, noise_scale)
|
36 |
+
_audio = model.slice_inference(out_wav_path, sid, vc_transform, slice_db, cluster_ratio, auto_f0, noise_scale)
|
37 |
+
return "转换成功", (44100, _audio)
|
|
|
|
|
|
|
|
|
38 |
|
39 |
|
40 |
app = gr.Blocks()
|
|
|
58 |
""")
|
59 |
spks = list(model.spk2id.keys())
|
60 |
sid = gr.Dropdown(label="音色", choices=["XT4.0"], value="XT4.0")
|
61 |
+
vc_input3 = gr.Audio(label="上传音频(长度建议小于90秒)")
|
62 |
vc_transform = gr.Number(label="变调(整数,可以正负,半音数量,升高八度就是12)", value=0)
|
63 |
cluster_ratio = gr.Number(label="聚类模型混合比例,0-1之间,默认为0不启用聚类,能提升音色相似度,但会导致咬字下降(如果使用建议0.5左右)", value=0)
|
64 |
auto_f0 = gr.Checkbox(label="自动f0预测,配合聚类模型f0预测效果更好,会导致变调功能失效(仅限转换语音,歌声不要勾选此项会究极跑调)", value=False)
|