Upload 2 files
Browse files- logs/44k/G_160000.pth +3 -0
- logs/44k/app.py +69 -0
logs/44k/G_160000.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:327077b358e87610e1257869510ebb5cc8466e0ce0cc872ca882b7c9069ff98b
|
| 3 |
+
size 542792859
|
logs/44k/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_160000.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(share=True)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|