Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
NaruseMioShirakana authored Feb 22, 2023
1 parent c7b3150 commit 516df39
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
Binary file added infer_tools/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added infer_tools/__pycache__/infer_tool.cpython-39.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions infer_tools/f0_temp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"info": "temp_dict"}
39 changes: 39 additions & 0 deletions infer_tools/infer_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from preprocessing.hubertinfer import Hubertencoder
from utils.hparams import hparams, set_hparams
from utils.pitch_utils import denorm_f0, norm_interp_f0
from modules.diff.diffusion_V2 import GaussianDiffusionOnnx

if os.path.exists("chunks_temp.json"):
os.remove("chunks_temp.json")
Expand Down Expand Up @@ -332,3 +333,41 @@ def processed_input2batch(samples):
'uv': uv,
}
return batch

class SvcOnnx:
def __init__(self, project_name, config_name, hubert_gpu, model_path):
self.project_name = project_name
self.DIFF_DECODERS = {
'wavenet': lambda hp: DiffNet(hp['audio_num_mel_bins']),
'fft': lambda hp: FFT(
hp['hidden_size'], hp['dec_layers'], hp['dec_ffn_kernel_size'], hp['num_heads']),
}

self.model_path = model_path
self.dev = torch.device("cuda")

self._ = set_hparams(config=config_name, exp_name=self.project_name, infer=True,
reset=True,
hparams_str='',
print_hparams=False)

self.mel_bins = hparams['audio_num_mel_bins']
self.model = GaussianDiffusionOnnx(
phone_encoder=Hubertencoder(hparams['hubert_path']),
out_dims=self.mel_bins, denoise_fn=self.DIFF_DECODERS[hparams['diff_decoder_type']](hparams),
timesteps=hparams['timesteps'],
K_step=hparams['K_step'],
loss_type=hparams['diff_loss_type'],
spec_min=hparams['spec_min'], spec_max=hparams['spec_max'],
)
self.load_ckpt()
self.model.cuda()
hparams['hubert_gpu'] = hubert_gpu
self.hubert = Hubertencoder(hparams['hubert_path'])
self.pe = PitchExtractor().cuda()
utils.load_ckpt(self.pe, hparams['pe_ckpt'], 'model', strict=True)
self.pe.eval()
self.vocoder = get_vocoder_cls(hparams)()

def load_ckpt(self, model_name='model', force=True, strict=True):
utils.load_ckpt(self.model, self.model_path, model_name, force, strict)

0 comments on commit 516df39

Please sign in to comment.