Skip SOS and EOS when processing sliced sentances (#179)

This commit is contained in:
OedoSoldier
2023-11-14 08:45:00 +08:00
committed by GitHub
parent 52f895aa9f
commit ad694ee050
2 changed files with 54 additions and 10 deletions

View File

@@ -125,6 +125,8 @@ def infer(
hps,
net_g,
device,
skip_start=False,
skip_end=False,
):
# 支持中日双语版本
inferMap_V2 = {
@@ -172,6 +174,20 @@ def infer(
bert, ja_bert, en_bert, phones, tones, lang_ids = get_text(
text, language, hps, device
)
if skip_start:
phones = phones[1:]
tones = tones[1:]
lang_ids = lang_ids[1:]
bert = bert[:, 1:]
ja_bert = ja_bert[:, 1:]
en_bert = en_bert[:, 1:]
if skip_end:
phones = phones[:-1]
tones = tones[:-1]
lang_ids = lang_ids[:-1]
bert = bert[:, :-1]
ja_bert = ja_bert[:, :-1]
en_bert = en_bert[:, :-1]
with torch.no_grad():
x_tst = phones.to(device).unsqueeze(0)
tones = tones.to(device).unsqueeze(0)