Skip to content

Commit

Permalink
fix hubert problems
Browse files Browse the repository at this point in the history
  • Loading branch information
prophesier committed Oct 26, 2022
1 parent 2c82a4a commit 9150767
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Diff-SVC
Singing Voice Conversion via diffusion model
## updates:
>2022.10.26 修复windows上预处理数据在linux上无法使用的问题,更新部分文档\
>2022.10.27 修复了一个严重错误,曾导致在gpu服务器上hubert仍使用cpu推理,速度减慢3-5倍,影响预处理与推理,不影响训练
2022.10.26 修复windows上预处理数据在linux上无法使用的问题,更新部分文档\
2022.10.25 编写推理/训练详细文档,修改整合部分代码,增加对ogg格式音频的支持(无需与wav区分,直接使用即可)\
2022.10.24 支持对自定义数据集的训练,并精简代码\
2022.10.22 完成对opencpop数据集的训练并创建仓库
Expand Down
7 changes: 7 additions & 0 deletions doc/train_and_inference.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ exp_name='这个项目的名称'
modelpath='ckpt文件的全路径'
如'./checkpoints/nyaru/model_ckpt_steps_112000.ckpt'
hparams['hubert_gpu']=False
推理时是否使用gpu推理hubert(模型中的一个模块),不影响模型的其他部分
如果打开,1分钟左右的音频这个模块将单独占用约5G+显存,显存较小不建议打开,已知1060系显卡会报错,请关闭
```
### 可调节参数:
```
Expand Down Expand Up @@ -90,6 +94,9 @@ test_prefixes:
hubert_path: checkpoints/hubert/hubert.onnx
hubert模型的存放地址,确保这个路径是对的,一般解压checkpoints包之后就是这个路径不需要改
hubert_gpu:True
是否在预处理时使用gpu运行hubert(模型的一个模块,显存占用较大),如显存不够大可关闭。
模型训练完推理是hubert是否用gpu可单独控制,不在本地预处理这里写true也没关系。
lr: 0.0008
#初始的学习率:这个数字对应于88的batchsize,如果batchsize更小,可以调低这个数值一些
Expand Down
2 changes: 1 addition & 1 deletion infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_step(sample, key, use_pe=True, **kwargs):
_ = set_hparams(config=f'checkpoints/{project_name}/config.yaml', exp_name=project_name, infer=True, reset=True,
hparams_str='',
print_hparams=False)

hparams['hubert_gpu']=False
mel_bins = hparams['audio_num_mel_bins']
model = GaussianDiffusion(
phone_encoder=Hubertencoder(hparams['hubert_path']),
Expand Down
1 change: 1 addition & 0 deletions inference.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"#===========这里填写checkpoints对应的exp_name(项目名,ckpt所在文件夹的名字),ckpt和config路径==========\n",
"_=set_hparams(config='./checkpoints/nyaru/config.yaml', exp_name='nyaru',infer=True,reset=True,hparams_str='', print_hparams=False)\n",
"modelpath='./checkpoints/nyaru/model_ckpt_steps_112000.ckpt'\n",
"hparams['hubert_gpu']=False\n",
"#=============================================================\n",
"mel_bins = hparams['audio_num_mel_bins']\n",
"model = GaussianDiffusion(\n",
Expand Down
10 changes: 9 additions & 1 deletion preprocessing/hubertinfer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import onnxruntime
import librosa
import numpy as np
from utils.hparams import hparams

class Hubertencoder():
def __init__(self,onnxpath='checkpoints/hubert/hubert.onnx'):
self.hubertsession=onnxruntime.InferenceSession(onnxpath,providers=['CPUExecutionProvider','CUDAExecutionProvider'])
if 'hubert_gpu' in hparams.keys():
self.use_gpu=hparams['hubert_gpu']
else:
self.use_gpu=True
if self.use_gpu:
self.hubertsession=onnxruntime.InferenceSession(onnxpath,providers=['CUDAExecutionProvider'])
else:
self.hubertsession=onnxruntime.InferenceSession(onnxpath,providers=['CPUExecutionProvider'])

def encode(self,wavpath):
wav, sr = librosa.load(wavpath,sr=None)
Expand Down
1 change: 1 addition & 0 deletions training/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ gen_tgt_spk_id: -1
hidden_size: 256
hop_size: 128
hubert_path: checkpoints/hubert/hubert.onnx
hubert_gpu: True
infer: false
keep_bins: 80
lambda_commit: 0.25
Expand Down

0 comments on commit 9150767

Please sign in to comment.