Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added data padding to 'forward', 'inference', and 'get_prosody_featur… #189

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions models/codec/ns3_codec/facodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,15 +811,28 @@ def __init__(

self.reset_parameters()

def _pad_data(self, x):
"""Pads the input audio data 'x'."""

remainder = x.size(-1) % self.hop_length
if remainder != 0:
pad_size = self.hop_length - remainder
else:
pad_size = 0
x_padded = F.pad(x, (0, pad_size))
return x_padded

def forward(self, x):
out = self.block(x)
return out
x_padded = self._pad_data(x)
return self.block(x_padded)

def inference(self, x):
return self.block(x)
x_padded = self._pad_data(x)
return self.block(x_padded)

def get_prosody_feature(self, x):
return self.mel_transform(x.squeeze(1))[:, :20, :]
x_padded = self._pad_data(x)
return self.mel_transform(x_padded.squeeze(1))[:, :20, :]

def remove_weight_norm(self):
"""Remove weight normalization module from all of the layers."""
Expand Down
Loading