Skip to content

Commit

Permalink
Fix typo, move check for set equality
Browse files Browse the repository at this point in the history
Signed-off-by: Jocelyn Huang <[email protected]>
  • Loading branch information
redoctopus committed Mar 20, 2023
1 parent 0635f47 commit a3bb341
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,13 @@ def __init__(
if fixed_vocab:
tokens = {self.text_preprocessing_func(c) for c in fixed_vocab}
self.set_fixed_vocab = True # Used to check whether dataset entries need filtering

if g2p.symbols == tokens:
logging.info(
"Did not replace G2P valid symbol set since the given set is equivalent to the existing one."
)
self.set_fixed_vocab = False
break
g2p.replace_symbols(tokens)
else:
tokens = set(g2p.symbols)
Expand Down
5 changes: 1 addition & 4 deletions nemo/collections/tts/g2p/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,11 @@ def replace_symbols(self, symbols, keep_alternate=True):
Args:
symbols (List, Set): User-provided set of valid symbols, both graphemes and phonemes
keep_alternate (bool): Whether to keep the other pronunciation(s) of a word if not all contain
illegal phonemes (and the word doesn't containi illegal graphemes).
illegal phonemes (and the word doesn't contain illegal graphemes).
Warning: this may change a word from being ambiguous to having only one valid pronunciation.
Defaults to True.
"""
new_symbols = set(symbols)
if self.symbols == new_symbols:
logging.info("Did not replace G2P valid symbol set since the given set is equivalent to the existing one.")
return

# Keep track of what will need to be deleted or (if keep_alternate=True) replaced
deletion_words = []
Expand Down

0 comments on commit a3bb341

Please sign in to comment.