Upload 4 files
Browse files- app.py +69 -0
- configs/config.json +98 -0
- logs/44k/G_71200.pth +3 -0
- logs/44k/kmeans_10000.pt +3 -0
app.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import io
|
2 |
+
import os
|
3 |
+
|
4 |
+
# os.system("wget -P cvec/ https://huggingface.co/spaces/innnky/nanami/resolve/main/checkpoint_best_legacy_500.pt")
|
5 |
+
import gradio as gr
|
6 |
+
import librosa
|
7 |
+
import numpy as np
|
8 |
+
import soundfile
|
9 |
+
from inference.infer_tool import Svc
|
10 |
+
import logging
|
11 |
+
|
12 |
+
logging.getLogger('numba').setLevel(logging.WARNING)
|
13 |
+
logging.getLogger('markdown_it').setLevel(logging.WARNING)
|
14 |
+
logging.getLogger('urllib3').setLevel(logging.WARNING)
|
15 |
+
logging.getLogger('matplotlib').setLevel(logging.WARNING)
|
16 |
+
|
17 |
+
config_path = "configs/config.json"
|
18 |
+
|
19 |
+
model = Svc("logs/44k/G_71200.pth", "configs/config.json", cluster_model_path="logs/44k/kmeans_10000.pt")
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
def vc_fn(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, noise_scale):
|
24 |
+
if input_audio is None:
|
25 |
+
return "You need to upload an audio", None
|
26 |
+
sampling_rate, audio = input_audio
|
27 |
+
# print(audio.shape,sampling_rate)
|
28 |
+
duration = audio.shape[0] / sampling_rate
|
29 |
+
if duration < 0:
|
30 |
+
return "请上传小于90s的音频,需要转换长音频请本地进行转换", None
|
31 |
+
audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32)
|
32 |
+
if len(audio.shape) > 1:
|
33 |
+
audio = librosa.to_mono(audio.transpose(1, 0))
|
34 |
+
if sampling_rate != 16000:
|
35 |
+
audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000)
|
36 |
+
print(audio.shape)
|
37 |
+
out_wav_path = "temp.wav"
|
38 |
+
soundfile.write(out_wav_path, audio, 16000, format="wav")
|
39 |
+
print( cluster_ratio, auto_f0, noise_scale)
|
40 |
+
_audio = model.slice_inference(out_wav_path, sid, vc_transform, slice_db, cluster_ratio, auto_f0, noise_scale)
|
41 |
+
return "Success", (44100, _audio)
|
42 |
+
|
43 |
+
|
44 |
+
app = gr.Blocks()
|
45 |
+
with app:
|
46 |
+
with gr.Tabs():
|
47 |
+
with gr.TabItem("Basic"):
|
48 |
+
gr.Markdown(value="""
|
49 |
+
sovits4.0 在线demo
|
50 |
+
|
51 |
+
此demo为预训练底模在线demo,使用数据:云灏 即霜 辉宇·星AI 派蒙 绫地宁宁
|
52 |
+
""")
|
53 |
+
spks = list(model.spk2id.keys())
|
54 |
+
sid = gr.Dropdown(label="音色", choices=spks, value=spks[0])
|
55 |
+
vc_input3 = gr.Audio(label="上传音频(长度小于90秒)")
|
56 |
+
vc_transform = gr.Number(label="变调(整数,可以正负,半音数量,升高八度就是12)", value=0)
|
57 |
+
cluster_ratio = gr.Number(label="聚类模型混合比例,0-1之间,默认为0不启用聚类,能提升音色相似度,但会导致咬字下降(如果使用建议0.5左右)", value=0)
|
58 |
+
auto_f0 = gr.Checkbox(label="自动f0预测,配合聚类模型f0预测效果更好,会导致变调功能失效(仅限转换语音,歌声不要勾选此项会究极跑调)", value=False)
|
59 |
+
slice_db = gr.Number(label="切片阈值", value=-40)
|
60 |
+
noise_scale = gr.Number(label="noise_scale 建议不要动,会影响音质,玄学参数", value=0.4)
|
61 |
+
vc_submit = gr.Button("转换", variant="primary")
|
62 |
+
vc_output1 = gr.Textbox(label="Output Message")
|
63 |
+
vc_output2 = gr.Audio(label="Output Audio")
|
64 |
+
vc_submit.click(vc_fn, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, slice_db, noise_scale], [vc_output1, vc_output2])
|
65 |
+
|
66 |
+
app.launch()
|
67 |
+
|
68 |
+
|
69 |
+
|
configs/config.json
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"train": {
|
3 |
+
"log_interval": 200,
|
4 |
+
"eval_interval": 800,
|
5 |
+
"seed": 1234,
|
6 |
+
"epochs": 10000,
|
7 |
+
"learning_rate": 0.0001,
|
8 |
+
"betas": [
|
9 |
+
0.8,
|
10 |
+
0.99
|
11 |
+
],
|
12 |
+
"eps": 1e-09,
|
13 |
+
"batch_size": 6,
|
14 |
+
"fp16_run": false,
|
15 |
+
"lr_decay": 0.999875,
|
16 |
+
"segment_size": 10240,
|
17 |
+
"init_lr_ratio": 1,
|
18 |
+
"warmup_epochs": 0,
|
19 |
+
"c_mel": 45,
|
20 |
+
"c_kl": 1.0,
|
21 |
+
"use_sr": true,
|
22 |
+
"max_speclen": 512,
|
23 |
+
"port": "8001",
|
24 |
+
"keep_ckpts": 3
|
25 |
+
},
|
26 |
+
"data": {
|
27 |
+
"training_files": "filelists/train.txt",
|
28 |
+
"validation_files": "filelists/val.txt",
|
29 |
+
"max_wav_value": 32768.0,
|
30 |
+
"sampling_rate": 44100,
|
31 |
+
"filter_length": 2048,
|
32 |
+
"hop_length": 512,
|
33 |
+
"win_length": 2048,
|
34 |
+
"n_mel_channels": 80,
|
35 |
+
"mel_fmin": 0.0,
|
36 |
+
"mel_fmax": 22050
|
37 |
+
},
|
38 |
+
"model": {
|
39 |
+
"inter_channels": 192,
|
40 |
+
"hidden_channels": 192,
|
41 |
+
"filter_channels": 768,
|
42 |
+
"n_heads": 2,
|
43 |
+
"n_layers": 6,
|
44 |
+
"kernel_size": 3,
|
45 |
+
"p_dropout": 0.1,
|
46 |
+
"resblock": "1",
|
47 |
+
"resblock_kernel_sizes": [
|
48 |
+
3,
|
49 |
+
7,
|
50 |
+
11
|
51 |
+
],
|
52 |
+
"resblock_dilation_sizes": [
|
53 |
+
[
|
54 |
+
1,
|
55 |
+
3,
|
56 |
+
5
|
57 |
+
],
|
58 |
+
[
|
59 |
+
1,
|
60 |
+
3,
|
61 |
+
5
|
62 |
+
],
|
63 |
+
[
|
64 |
+
1,
|
65 |
+
3,
|
66 |
+
5
|
67 |
+
]
|
68 |
+
],
|
69 |
+
"upsample_rates": [
|
70 |
+
8,
|
71 |
+
8,
|
72 |
+
2,
|
73 |
+
2,
|
74 |
+
2
|
75 |
+
],
|
76 |
+
"upsample_initial_channel": 512,
|
77 |
+
"upsample_kernel_sizes": [
|
78 |
+
16,
|
79 |
+
16,
|
80 |
+
4,
|
81 |
+
4,
|
82 |
+
4
|
83 |
+
],
|
84 |
+
"n_layers_q": 3,
|
85 |
+
"use_spectral_norm": false,
|
86 |
+
"gin_channels": 256,
|
87 |
+
"ssl_dim": 256,
|
88 |
+
"n_speakers": 200
|
89 |
+
},
|
90 |
+
"spk": {
|
91 |
+
"Yaoyao": 0,
|
92 |
+
"Diona": 1,
|
93 |
+
"Klee": 2,
|
94 |
+
"Nahida": 3,
|
95 |
+
"Qiqi": 4,
|
96 |
+
"Sayu": 5
|
97 |
+
}
|
98 |
+
}
|
logs/44k/G_71200.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5aad12454bd7555c414db6c3b3a82a19b3142168420e455a51856a60bbc29ba8
|
3 |
+
size 542789405
|
logs/44k/kmeans_10000.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7a3108ac8051ed3c0e420cab2d2fca099adb532174b3948e9b1370dd6b7d5c64
|
3 |
+
size 92650425
|