Skip to content

Commit

Permalink
Made backward compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: treacker <[email protected]>
  • Loading branch information
treacker committed May 5, 2022
1 parent 71cc60c commit 16d6bc0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions nemo/collections/tts/models/tacotron2.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,14 @@ def __init__(self, cfg: DictConfig, trainer: 'Trainer' = None):
self.postnet = instantiate(self._cfg.postnet)
self.loss = Tacotron2Loss()
self.calculate_loss = True

@property
def parser(self):
if self._parser is not None:
return self._parser

ds_class_name = self._cfg.train_ds.dataset._target_.split(".")[-1]
if ds_class_name == "TTSDataset":
self._parser = None
elif ds_class_name == "AudioToCharDataset":
self._parser = self.vocab.encode
elif hasattr(self._cfg, "labels"):
self._parser = parsers.make_parser(
labels=self._cfg.labels,
Expand All @@ -133,9 +130,10 @@ def parser(self):
abbreviation_version="fastpitch",
make_table=False,
)
elif ds_class_name == "AudioToCharWithPriorAndPitchDataset":
self.parser = self.vocab.encode
else:
raise ValueError("Wanted to setup parser, but model does not have necessary paramaters")

return self._parser

def parse(self, text: str, normalize=True) -> torch.Tensor:
Expand Down

0 comments on commit 16d6bc0

Please sign in to comment.