Update use_diffuse_tts
This commit is contained in:
parent
a77d376ad2
commit
e0e36ed98c
|
@ -22,13 +22,15 @@ if __name__ == '__main__':
|
|||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-opt', type=str, help='Path to options YAML file used to train the diffusion model', default='X:\\dlas\\experiments\\train_diffusion_tts_medium\\train_diffusion_tts_medium.yml')
|
||||
parser.add_argument('-diffusion_model_name', type=str, help='Name of the diffusion model in opt.', default='generator')
|
||||
parser.add_argument('-diffusion_model_path', type=str, help='Path to saved model weights', default='X:\\dlas\\experiments\\train_diffusion_tts_medium\\models\\22500_generator_ema.pth')
|
||||
parser.add_argument('-diffusion_model_path', type=str, help='Path to saved model weights', default='X:\\dlas\\experiments\\train_diffusion_tts_medium\\models\\38500_generator_ema.pth')
|
||||
parser.add_argument('-aligned_codes', type=str, help='Comma-delimited list of integer codes that defines text & prosody. Get this by apply W2V to an existing audio clip or from a bespoke generator.',
|
||||
default='0,0,0,0,10,10,0,4,0,7,0,17,4,4,0,25,5,0,13,13,0,22,4,4,0,21,15,15,7,0,0,14,4,4,6,8,4,4,0,0,12,5,0,0,5,0,4,4,22,22,8,16,16,0,4,4,4,0,0,0,0,0,0,0') # Default: 'i am very glad to see you', libritts/train-clean-100/103/1241/103_1241_000017_000001.wav.
|
||||
# -cond "Y:\libritts/train-clean-100/103/1241/103_1241_000017_000001.wav"
|
||||
parser.add_argument('-cond', type=str, help='Path to the conditioning input audio file.', default='Y:\\clips\\books1\\754_Dan Simmons - The Rise Of Endymion 356 of 450\\00026.wav')
|
||||
parser.add_argument('-diffusion_steps', type=int, help='Number of diffusion steps to perform to create the generate. Lower steps reduces quality, but >40 is generally pretty good.', default=100)
|
||||
parser.add_argument('-output_path', type=str, help='Where to store outputs.', default='../results/use_diffuse_tts')
|
||||
parser.add_argument('-sample_rate', type=int, help='Model sample rate', default=11025)
|
||||
parser.add_argument('-cond_sample_rate', type=int, help='Model sample rate', default=22050)
|
||||
parser.add_argument('-device', type=str, help='Device to run on', default='cpu')
|
||||
args = parser.parse_args()
|
||||
os.makedirs(args.output_path, exist_ok=True)
|
||||
|
@ -36,12 +38,12 @@ if __name__ == '__main__':
|
|||
print("Loading Diffusion Model..")
|
||||
diffusion = load_model_from_config(args.opt, args.diffusion_model_name, also_load_savepoint=False,
|
||||
load_path=args.diffusion_model_path, device=args.device)
|
||||
aligned_codes_compression_factor = 221 # Derived empirically for 11025Hz sample rate. Adjust if sample rate increases.
|
||||
aligned_codes_compression_factor = args.sample_rate * 221 // 11025
|
||||
|
||||
print("Loading data..")
|
||||
aligned_codes = torch.tensor([int(s) for s in args.aligned_codes.split(',')]).to(args.device)
|
||||
diffuser = load_discrete_vocoder_diffuser(desired_diffusion_steps=args.diffusion_steps)
|
||||
cond = load_audio(args.cond, 22050).to(args.device)
|
||||
cond = load_audio(args.cond, args.cond_sample_rate).to(args.device)
|
||||
if cond.shape[-1] > 88000:
|
||||
cond = cond[:,:88000]
|
||||
|
||||
|
@ -53,10 +55,10 @@ if __name__ == '__main__':
|
|||
output = diffuser.p_sample_loop(diffusion, output_shape, noise=torch.zeros(output_shape, device=args.device),
|
||||
model_kwargs={'tokens': aligned_codes.unsqueeze(0),
|
||||
'conditioning_input': cond.unsqueeze(0)})
|
||||
torchaudio.save(os.path.join(args.output_path, f'output_mean.wav'), output.cpu().squeeze(0), 11025)
|
||||
torchaudio.save(os.path.join(args.output_path, f'output_mean.wav'), output.cpu().squeeze(0), args.sample_rate)
|
||||
|
||||
for k in range(5):
|
||||
output = diffuser.p_sample_loop(diffusion, output_shape, model_kwargs={'tokens': aligned_codes.unsqueeze(0),
|
||||
'conditioning_input': cond.unsqueeze(0)})
|
||||
|
||||
torchaudio.save(os.path.join(args.output_path, f'output_{k}.wav'), output.cpu().squeeze(0), 11025)
|
||||
torchaudio.save(os.path.join(args.output_path, f'output_{k}.wav'), output.cpu().squeeze(0), args.sample_rate)
|
||||
|
|
Loading…
Reference in New Issue
Block a user