import soundfile | |
from infer_pack.onnx_inference import OnnxRVC | |
hop_size = 512 | |
sampling_rate = 40000 # Sampling rate | |
f0_up_key = 0 # rising and falling tones | |
sid = 0 # Role ID | |
f0_method = "dio" # F0 extraction algorithm | |
model_path = "ShirohaRVC.onnx" # full path to model | |
vec_name = "vec-256-layer-9" # The internal automatic completion is f"pretrained/{vec_name}.onnx" requires the onnx vec model | |
wav_path = "123.wav" # Input path or ByteIO instance | |
out_path = "out.wav" # Output path or ByteIO instance | |
model = OnnxRVC( | |
model_path, vec_path=vec_name, sr=sampling_rate, hop_size=hop_size, device="cuda" | |
) | |
audio = model.inference(wav_path, sid, f0_method=f0_method, f0_up_key=f0_up_key) | |
soundfile.write(out_path, audio, sampling_rate) | |