Skip CLVP if cvvp_amount is 1

Also fixes formatting bug in log message
This commit is contained in:
Johan Nordberg 2022-05-25 11:12:53 +00:00
parent a52e3026ba
commit b681fa9d11

View File

@ -427,16 +427,20 @@ class TextToSpeech:
if self.cvvp is None: if self.cvvp is None:
print("Computing best candidates using CLVP") print("Computing best candidates using CLVP")
else: else:
print(f"Computing best candidates using CLVP {int((1-cvvp_amount) * 100):02d}% and CVVP {int(cvvp_amount * 100):02d}%") print(f"Computing best candidates using CLVP {((1-cvvp_amount) * 100):2.0f}% and CVVP {(cvvp_amount * 100):2.0f}%")
for batch in tqdm(samples, disable=not verbose): for batch in tqdm(samples, disable=not verbose):
for i in range(batch.shape[0]): for i in range(batch.shape[0]):
batch[i] = fix_autoregressive_output(batch[i], stop_mel_token) batch[i] = fix_autoregressive_output(batch[i], stop_mel_token)
if cvvp_amount != 1:
clvp = self.clvp(text_tokens.repeat(batch.shape[0], 1), batch, return_loss=False) clvp = self.clvp(text_tokens.repeat(batch.shape[0], 1), batch, return_loss=False)
if auto_conds is not None and cvvp_amount > 0: if auto_conds is not None and cvvp_amount > 0:
cvvp_accumulator = 0 cvvp_accumulator = 0
for cl in range(auto_conds.shape[1]): for cl in range(auto_conds.shape[1]):
cvvp_accumulator = cvvp_accumulator + self.cvvp(auto_conds[:, cl].repeat(batch.shape[0], 1, 1), batch, return_loss=False) cvvp_accumulator = cvvp_accumulator + self.cvvp(auto_conds[:, cl].repeat(batch.shape[0], 1, 1), batch, return_loss=False)
cvvp = cvvp_accumulator / auto_conds.shape[1] cvvp = cvvp_accumulator / auto_conds.shape[1]
if cvvp_amount == 1:
clip_results.append(cvvp)
else:
clip_results.append(cvvp * cvvp_amount + clvp * (1-cvvp_amount)) clip_results.append(cvvp * cvvp_amount + clvp * (1-cvvp_amount))
else: else:
clip_results.append(clvp) clip_results.append(clvp)