1
0
mirror of https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git synced 2026-06-05 01:10:22 +08:00
Files
Retrieval-based-Voice-Conve…/tools/onnx/onnx_inference_demo.py
github-actions[bot] e2fcbff1e9 chore(format): run black on dev (#2)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-05 21:30:15 +09:00

25 lines
730 B
Python

import soundfile
import librosa
from rvc.onnx.infer import RVC
hop_size = 512
sampling_rate = 40000 # 采样率
f0_up_key = 0 # 升降调
sid = 0 # 角色ID
f0_method = "dio" # F0提取算法
model_path = "exported_model.onnx" # 模型的完整路径
vec_path = "vec-256-layer-9.onnx" # 需要onnx的vec模型
wav_path = "123.wav" # 输入路径或ByteIO实例
out_path = "out.wav" # 输出路径或ByteIO实例
model = RVC(
model_path, vec_path=vec_path, sr=sampling_rate, hop_size=hop_size, device="cuda"
)
wav, sr = librosa.load(wav_path, sr=sampling_rate)
audio = model.inference(wav, sr, sid, f0_method=f0_method, f0_up_key=f0_up_key)
soundfile.write(out_path, audio, sampling_rate)