Skip to content

Commit

Permalink
[TTS] add staticmethod decoration for BetaBinomialInterpolator (#4319)
Browse files Browse the repository at this point in the history
Signed-off-by: Xuesong Yang <xuesongyxs@gmail.com>
  • Loading branch information
XuesongYang authored Jun 3, 2022
1 parent 91073f7 commit a26a891
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nemo/collections/tts/torch/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a26a891

Please sign in to comment.