Spaces:
Build error
Build error
File size: 895 Bytes
471bf00 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import json
import os
import time
import re
import numpy as np
import soundfile
import torch
import tqdm
from scipy.interpolate import interp1d
from utils import utils
from egs.visinger2.models import SynthesizerTrn
from infer import preprocess, cross_fade, infer_ds
trans = -12
speaker = "otto"
ds_path = "infer/share.ds"
config_json = "egs/visinger2/config.json"
checkpoint_path = f"/Volumes/Extend/下载/G_110000.pth"
file_name = os.path.splitext(os.path.basename(ds_path))[0]
step = re.findall(r'G_(\d+)\.pth', checkpoint_path)[0]
if __name__ == '__main__':
ds = json.load(open(ds_path))
hps = utils.get_hparams_from_file(config_json)
net_g = SynthesizerTrn(hps)
_ = net_g.eval()
_ = utils.load_checkpoint(checkpoint_path, net_g, None)
audio = infer_ds(net_g, hps, ds, speaker, trans)
soundfile.write(f"{speaker}_{file_name}_{step}step.wav", audio, 44100)
|