import io import os # os.system("wget -P cvec/ https://huggingface.co/spaces/innnky/nanami/resolve/main/checkpoint_best_legacy_500.pt") import gradio as gr import librosa import numpy as np import soundfile from inference.infer_tool import Svc import logging logging.getLogger('numba').setLevel(logging.WARNING) logging.getLogger('markdown_it').setLevel(logging.WARNING) logging.getLogger('urllib3').setLevel(logging.WARNING) logging.getLogger('matplotlib').setLevel(logging.WARNING) config_path = "models/yukimi/config.json" model = Svc("models/yukimi/G_1467.pth", "models/yukimi/config.json") # model = Svc("E:/Items/so-vits-svc/models/Arknights/G_10400.pth", "E:/Items/so-vits-svc/models/Arknights/config.json") def vc_fn(sid, input_audio, vc_transform, auto_f0,cluster_ratio, slice_db, noise_scale): if input_audio is None: return "音声をアップロードしてください", None sampling_rate, audio = input_audio # print(audio.shape,sampling_rate) duration = audio.shape[0] / sampling_rate if duration > 90: return "90 秒未満の音声をアップロードしてください", None audio = (audio / np.iinfo(audio.dtype).max).astype(np.float32) if len(audio.shape) > 1: audio = librosa.to_mono(audio.transpose(1, 0)) if sampling_rate != 16000: audio = librosa.resample(audio, orig_sr=sampling_rate, target_sr=16000) print(audio.shape) out_wav_path = "temp.wav" soundfile.write(out_wav_path, audio, 16000, format="wav") print( cluster_ratio, auto_f0, noise_scale) _audio = model.slice_inference(out_wav_path, sid, vc_transform, slice_db, cluster_ratio, auto_f0, noise_scale) return "Success", (44100, _audio) app = gr.Blocks() with app: with gr.Tabs(): with gr.TabItem("Basic"): gr.Markdown(value=""" so-vits-svc-fork oユキミo の音声変換モデル """) spks = list(model.spk2id.keys()) sid = gr.Dropdown(label="モデル", choices=spks, value=spks[0]) vc_input3 = gr.Audio(label="変換する音声 ( 90秒未満 )") vc_transform = gr.Number(label="ピッチ調整 ( 半音単位で正負値を指定 )", value=0) cluster_ratio = gr.Number(label="クラスタリングレート ( デフォルトの 0 を推奨 )", value=0) auto_f0 = gr.Checkbox(label="ピッチ予測 ( セリフの場合はオン、ボーカルの場合はオフにして下さい )", value=False) slice_db = gr.Number(label="無音しきい値", value=-40) noise_scale = gr.Number(label="ノイズスケール ( 変更しないことを推奨 )", value=0.4) vc_submit = gr.Button("変換", variant="primary") vc_output1 = gr.Textbox(label="Output Message") vc_output2 = gr.Audio(label="Output Audio") vc_submit.click(vc_fn, [sid, vc_input3, vc_transform,auto_f0,cluster_ratio, slice_db, noise_scale], [vc_output1, vc_output2]) app.launch()