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

Add finetuning support for Speaker class #679

Merged
merged 4 commits into from
Aug 14, 2024

Conversation

ain-soph
Copy link
Contributor

@ain-soph ain-soph commented Aug 10, 2024

To allow tuning for speaker_embeds tensor. The PR includes:

  1. Rename: _sample_random -> sample_random_tensor to allow usage out of class.
  2. The spk_emb argument in Speaker.apply() changes str -> Union[str, torch.Tensor]
  3. Add inplace argument to support gradient backward when setting to False
  4. Update return type to return torch.Tensor

Besides, I don't quite see the advantage and motivation to encode the speaker_embeds tensor to string. To me, it only makes things more complex. I would personally prefer cpu torch.Tensor or np.ndarray

cc @fumiama

Copy link
Member

@fumiama fumiama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides, I don't quite see the advantage and motivation to encode the speaker_embeds tensor to string.

People can still use the tensor but the .pt file can easily contains virus. The str encoding is equal to the numpy array dump but is easy to copy&paste.

@fumiama
Copy link
Member

fumiama commented Aug 11, 2024

Also, you can save the str to a txt file (with the ext .pt if you like) and use it just like a .pt file if you like.

@ain-soph
Copy link
Contributor Author

ain-soph commented Aug 11, 2024

Also, you can save the str to a txt file (with the ext .pt if you like) and use it just like a .pt file if you like.

"use it just like a .pt file if you like" -> You mean we could directly read the tensor via torch.load() instead of using pybase16384 to encode/decode? I didn't know that.

@fumiama
Copy link
Member

fumiama commented Aug 11, 2024

Also, you can save the str to a txt file (with the ext .pt if you like) and use it just like a .pt file if you like.

"use it just like a .pt file if you like" -> You mean we could directly read the tensor via torch.load() instead of using pybase16384 to encode/decode? I didn't know that.

Just treat the str as a kind of binary.

@fumiama fumiama added the enhancement New feature or request label Aug 11, 2024
@ain-soph ain-soph requested a review from fumiama August 11, 2024 15:11
Copy link
Member

@fumiama fumiama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fumiama fumiama merged commit d93ed8d into 2noise:dev Aug 14, 2024
5 checks passed
@ain-soph ain-soph deleted the speaker-support-finetuning branch August 14, 2024 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants