How can we get features from wav2vec 2.0
See original GitHub issue❓ Questions and Help
Before asking:
- search the issues.
- search the docs.
What is your question?
Hi, for wav2vec 2.0, how can I get pre-trained features like wav2vec? https://github.com/pytorch/fairseq/tree/master/examples/wav2vec#pre-trained-models-1
My error ⬇️ /content/fairseq/fairseq/models/wav2vec/wav2vec2.py in init(self, cfg) 244 self.mask_prob = cfg.mask_prob 245 self.mask_selection = cfg.mask_selection –> 246 self.mask_other = cfg.mask_other 247 self.mask_length = cfg.mask_length 248 self.no_mask_overlap = cfg.no_mask_overlap
AttributeError: ‘Namespace’ object has no attribute ‘mask_other’
Code
import torch
from fairseq.models.wav2vec import Wav2Vec2Model
cp = torch.load('/content/pretrain_model/wav2vec_vox_new.pt')
model = Wav2Vec2Model.build_model(cp['args'], task=None)
model.load_state_dict(cp['model'])
model.eval()
wav_input_16khz = torch.randn(1,10000)
z = model.feature_extractor(wav_input_16khz)
c = model.feature_aggregator(z)
What’s your environment?
- fairseq Version (e.g., 1.0 or master):
- PyTorch Version (e.g., 1.0) 1.7.0
- OS (e.g., Linux):
- How you installed fairseq (
pip
, source): cd fairseq pip install --editable ./ - Build command you used (if compiling from source):
- Python version: 3.7
- CUDA/cuDNN version: 10.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:14 (4 by maintainers)
Top Results From Across the Web
How can we get features from wav2vec 2.0 #2967 - GitHub
To extract features you can use method suggested above: via model forward (with mask=False and features_only=True).
Read more >Wav2Vec2 - Hugging Face
Overview. The Wav2Vec2 model was proposed in wav2vec 2.0: A Framework for Self-Supervised Learning of Speech Representations by Alexei Baevski, Henry Zhou, ...
Read more >An Illustrated Tour of Wav2vec 2.0 | Jonathan Bgn
Feature encoder. The feature encoder's job is to reduce the dimensionality of the audio data, converting the raw waveform into a sequence of ......
Read more >Audio Features from the Wav2Vec 2.0 Embeddings for the ...
For this purpose, we have investigated the Wav2Vec 2.0 deep neural network to extract audio features from Transformer embeddings.
Read more >Wav2Vec 2.0: Self-Supervised Learning for ASR
Wav2Vec 2.0 : state-of-the-art model for Automatic Speech Recognition. It takes advantage from a self-supervised training and contrastive learning.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
can you load it like this instead:
after that you can extract features from feature encoder in the way you tried it, or from the transformer by just doing a model forward (with mask=False and features_only=True). you may also want to try features from different layers of the model, but you need to make some changes to return results from each layer, here: https://github.com/pytorch/fairseq/blob/master/fairseq/models/wav2vec/wav2vec2.py#L764 and then also in the model forward()
Have been facing a same problem. Faced many compatibility issues. Turns out the reason was that pip source was not updated. I tried to install and develop locally. Then XLS43, wav2vec_large,wav2vec_small everything was working properly.