Upload onnx_inference_demo.py with huggingface_hub
Browse files- onnx_inference_demo.py +20 -0
onnx_inference_demo.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import soundfile
|
2 |
+
from infer_pack.onnx_inference import OnnxRVC
|
3 |
+
|
4 |
+
hop_size = 512
|
5 |
+
sampling_rate = 40000 # 采样率
|
6 |
+
f0_up_key = 0 # 升降调
|
7 |
+
sid = 0 # 角色ID
|
8 |
+
f0_method = "dio" # F0提取算法
|
9 |
+
model_path = "ShirohaRVC.onnx" # 模型的完整路径
|
10 |
+
vec_name = "vec-256-layer-9" # 内部自动补齐为 f"pretrained/{vec_name}.onnx" 需要onnx的vec模型
|
11 |
+
wav_path = "123.wav" # 输入路径或ByteIO实例
|
12 |
+
out_path = "out.wav" # 输出路径或ByteIO实例
|
13 |
+
|
14 |
+
model = OnnxRVC(
|
15 |
+
model_path, vec_path=vec_name, sr=sampling_rate, hop_size=hop_size, device="cuda"
|
16 |
+
)
|
17 |
+
|
18 |
+
audio = model.inference(wav_path, sid, f0_method=f0_method, f0_up_key=f0_up_key)
|
19 |
+
|
20 |
+
soundfile.write(out_path, audio, sampling_rate)
|