CoolFace
Apppublic

mitudesk/uma_diffsvc

sourceHugging Faceapache-2.0updated 4y agoView on Hugging Face
0likes
batch.py44 linesDownload Raw Back to root
1import soundfile2 3from infer_tools import infer_tool4from infer_tools.infer_tool import Svc5 6 7def run_clip(svc_model, key, acc, use_pe, use_crepe, thre, use_gt_mel, add_noise_step, project_name='', f_name=None,8             file_path=None, out_path=None):9    raw_audio_path = f_name10    infer_tool.format_wav(raw_audio_path)11    _f0_tst, _f0_pred, _audio = svc_model.infer(raw_audio_path, key=key, acc=acc, singer=True, use_pe=use_pe,12                                                use_crepe=use_crepe,13                                                thre=thre, use_gt_mel=use_gt_mel, add_noise_step=add_noise_step)14    out_path = f'./singer_data/{f_name.split("/")[-1]}'15    soundfile.write(out_path, _audio, 44100, 'PCM_16')16 17 18if __name__ == '__main__':19    # 工程文件夹名,训练时用的那个20    project_name = "firefox"21    model_path = f'./checkpoints/{project_name}/clean_model_ckpt_steps_100000.ckpt'22    config_path = f'./checkpoints/{project_name}/config.yaml'23 24    # 支持多个wav/ogg文件,放在raw文件夹下,带扩展名25    file_names = infer_tool.get_end_file("./batch", "wav")26    trans = [-6]  # 音高调整,支持正负(半音),数量与上一行对应,不足的自动按第一个移调参数补齐27    # 加速倍数28    accelerate = 5029    hubert_gpu = True30    cut_time = 3031 32    # 下面不动33    infer_tool.mkdir(["./batch", "./singer_data"])34    infer_tool.fill_a_to_b(trans, file_names)35 36    model = Svc(project_name, config_path, hubert_gpu, model_path)37    count = 038    for f_name, tran in zip(file_names, trans):39        print(f_name)40        run_clip(model, key=tran, acc=accelerate, use_crepe=False, thre=0.05, use_pe=False, use_gt_mel=False,41                 add_noise_step=500, f_name=f_name, project_name=project_name)42        count += 143        print(f"process:{round(count * 100 / len(file_names), 2)}%")44