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

How to extract weighted sum SSL representations from an audio dataset? #539

Open
mukherjeesougata opened this issue May 6, 2024 · 0 comments

Comments

@mukherjeesougata
Copy link

mukherjeesougata commented May 6, 2024

Weighted sum can be extracted from the Featurizer class and the code snippet for its extraction is as follows:-

 >>> import torch
 >>> from s3prl.nn import S3PRLUpstream, Featurizer
  ...
 >>> model = S3PRLUpstream("hubert")
 >>> model.eval()
  ...
 >>> with torch.no_grad():
 ...     wavs = torch.randn(2, 16000 * 2)
 ...     wavs_len = torch.LongTensor([16000 * 1, 16000 * 2])
 ...     all_hs, all_hs_len = model(wavs, wavs_len)
 ...
>>> featurizer = Featurizer(model)
>>> hs, hs_len = featurizer(all_hs, all_hs_len)

But How shall I modify this code so that I will get the weighted sum features/representations hs for each audio file from an audio dataset and store it as features for each corresponding audio file?
I think the modification needs to be done in the following 2 lines:-

        ...     wavs = torch.randn(2, 16000 * 2)
        ...     wavs_len = torch.LongTensor([16000 * 1, 16000 * 2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant