Conversation
Signed-off-by: Paarth Neekhara <paarth.n@gmail.com>
| If the model has a baked context embedding, the context_encoder weights are also excluded | ||
| since they are no longer needed for inference. | ||
| """ | ||
| def state_dict(self, destination=None, prefix='', keep_vars=False): |
There was a problem hiding this comment.
Can you add back the docstring?
There was a problem hiding this comment.
added the docstrings.
|
|
||
| _speaker_verification_model is only included in older checkpoints with the older single_encoder_sv_tts | ||
| model_type that is no longer supported and can likely be removed in a future version. | ||
| def _get_state_dict_keys_to_exclude(self): |
There was a problem hiding this comment.
Can you add a docstring to this?
There was a problem hiding this comment.
added the docstrings.
| def remove_bos_token(codes, codes_len, num_tokens=1): | ||
| codes = codes[:, :, num_tokens:] | ||
| codes_len = codes_len - num_tokens | ||
| return codes, codes_len | ||
|
|
||
|
|
||
| def remove_embedded_bos_token(embedded, embedded_len): | ||
| embedded = embedded[:, 1:, :] | ||
| embedded_len = embedded_len - 1 | ||
| return embedded, embedded_len |
There was a problem hiding this comment.
These two functions look identical. Do we need both?
There was a problem hiding this comment.
Yeah, both of them were there earlier and being used. One does the removal in the embedded tensor and one does the removal in code tensor (before embedding). They are also different in their implementation.
| def remove_eos_token(codes, codes_len): | ||
| codes_len = codes_len - 1 | ||
| codes = codes[:, :, :-1] | ||
| mask = get_mask_from_lengths(lengths=codes_len) | ||
| codes = codes * mask.unsqueeze(1) | ||
| return codes, codes_len | ||
|
|
||
|
|
||
| def remove_embedded_eos_token(embedded, embedded_len): | ||
| """Remove the last token from embedded sequences. | ||
|
|
||
| Args: | ||
| embedded: (B, T', D) | ||
| """ | ||
| embedded_len = embedded_len - 1 | ||
| embedded = embedded[:, :-1, :] | ||
| mask = get_mask_from_lengths(lengths=embedded_len) | ||
| embedded = embedded * mask.unsqueeze(2) | ||
| return embedded, embedded_len |
There was a problem hiding this comment.
These two functions look identical. Do we need both?
There was a problem hiding this comment.
Same as the above.
Signed-off-by: Paarth Neekhara <paarth.n@gmail.com>
This change is mainly done because EasyMagpie will be reusing some shared functionalities with Magpie. So to avoid code duplication, we are moving common things together.
After this, i will raise a separate PR for EasyMagpie changes.