import transformers
import librosa
import soundfile as sf
import torch
from transformers import Wav2Vec2ForCTC
from transformers import Wav2Vec2Tokenizer
#load model and tokenizer
tokenizer = Wav2Vec2Tokenizer.from_pretrained(“facebook/wav2vec2-base-960h”)
model = Wav2Vec2ForCTC.from_pretrained(“facebook/wav2vec2-base-960h”)
I get:
ImportError Traceback (most recent call last)
in
3 import soundfile as sf
4 import torch
----> 5 from transformers import Wav2Vec2ForCTC
6 from transformers import Wav2Vec2Tokenizer
7
ImportError: cannot import name ‘Wav2Vec2ForCTC’ from ‘transformers’ (c:\python\python37\lib\site-packages\transformers_init_.py)
How I install/get Wav2Vec2ForCTC and Wav2Vec2Tokenizer ???
I had the same issue. I upgraded the transformers version from 4.3.0 to 4.3.2 with pip install transformers==4.3.2
and that worked for me. Also, upgrade your PyTorch to its latest version 1.7 with pip install torch==1.7
that avoids error while loading pre-trained weights in the next step.