Skip to content

Commit

Permalink
unknown token fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pradnya-git-dev committed Jul 3, 2023
1 parent 9937302 commit 2905a52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions recipes/LJSpeech/TTS/fastspeech2/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ def dataio_prepare(hparams):
# add a dummy symbol for idx 0 - used for padding.
lexicon = ["@@"] + lexicon
input_encoder.update_from_iterable(lexicon, sequence_input=False)
input_encoder.add_unk()

# load audio, text and durations on the fly; encode audio and text.
@sb.utils.data_pipeline.takes(
Expand Down Expand Up @@ -502,6 +503,7 @@ def audio_pipeline(
label_phoneme = label_phoneme.strip()
label_phoneme = label_phoneme.split()
text_seq = input_encoder.encode_sequence_torch(label_phoneme).int()

assert len(text_seq) == len(
durs
), f"{len(text_seq)}, {len(durs), len(label_phoneme)}, ({label_phoneme})" # ensure every token has a duration
Expand Down
2 changes: 2 additions & 0 deletions speechbrain/pretrained/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -2858,6 +2858,8 @@ def __init__(self, *args, **kwargs):
lexicon = ["@@"] + lexicon
self.input_encoder = self.hparams.input_encoder
self.input_encoder.update_from_iterable(lexicon, sequence_input=False)
self.input_encoder.add_unk()

self.g2p = GraphemeToPhoneme.from_hparams("speechbrain/soundchoice-g2p")

self.spn_token_encoded = (
Expand Down

0 comments on commit 2905a52

Please sign in to comment.