From a26a8912b6a1832981df5068d25fd24760e6bf0f Mon Sep 17 00:00:00 2001 From: Xuesong Yang Date: Fri, 3 Jun 2022 13:00:53 -0700 Subject: [PATCH] [TTS] add staticmethod decoration for BetaBinomialInterpolator (#4319) Signed-off-by: Xuesong Yang --- nemo/collections/tts/torch/helpers.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nemo/collections/tts/torch/helpers.py b/nemo/collections/tts/torch/helpers.py index 250c71ba0442..c144681cb0fe 100644 --- a/nemo/collections/tts/torch/helpers.py +++ b/nemo/collections/tts/torch/helpers.py @@ -31,12 +31,13 @@ def __init__(self, round_mel_len_to=50, round_text_len_to=10, cache_size=500): self.round_text_len_to = round_text_len_to self.bank = functools.lru_cache(maxsize=cache_size)(beta_binomial_prior_distribution) - def round(self, val, to): + @staticmethod + def round(val, to): return max(1, int(np.round((val + 1) / to))) * to def __call__(self, w, h): - bw = self.round(w, to=self.round_mel_len_to) - bh = self.round(h, to=self.round_text_len_to) + bw = BetaBinomialInterpolator.round(w, to=self.round_mel_len_to) + bh = BetaBinomialInterpolator.round(h, to=self.round_text_len_to) ret = ndimage.zoom(self.bank(bw, bh).T, zoom=(w / bw, h / bh), order=1) assert ret.shape[0] == w, ret.shape assert ret.shape[1] == h, ret.shape