voice-changer/server/voice_changer/RVC/inferencer/OnnxRVCInferencerNono.py

36 lines
1.1 KiB
Python
Raw Normal View History

2023-05-02 14:57:12 +03:00
import torch
import numpy as np
2023-05-03 07:14:00 +03:00
from voice_changer.RVC.inferencer.OnnxRVCInferencer import OnnxRVCInferencer
2023-05-02 14:57:12 +03:00
2023-05-03 07:14:00 +03:00
class OnnxRVCInferencerNono(OnnxRVCInferencer):
2023-05-02 14:57:12 +03:00
def infer(
self,
feats: torch.Tensor,
pitch_length: torch.Tensor,
pitch: torch.Tensor | None,
pitchf: torch.Tensor | None,
sid: torch.Tensor,
) -> torch.Tensor:
if self.isHalf:
audio1 = self.model.run(
["audio"],
{
"feats": feats.cpu().numpy().astype(np.float16),
"p_len": pitch_length.cpu().numpy().astype(np.int64),
"sid": sid.cpu().numpy().astype(np.int64),
},
)
else:
audio1 = self.model.run(
["audio"],
{
"feats": feats.cpu().numpy().astype(np.float32),
"p_len": pitch_length.cpu().numpy().astype(np.int64),
"sid": sid.cpu().numpy().astype(np.int64),
},
)
return torch.tensor(np.array(audio1))