Wav2Vec2ForCTC and Wav2Vec2Tokenizer
Having installed transformers and trying:import transformersimport librosaimport soundfile as sfimport torchfrom transformers import Wav2Vec2ForCTCfrom transformers import Wav2Vec2Tokenizer#loadmodel and tokenizertokenizer = Wav2Vec2Tokenizer.from_pretrained(“facebook/wav2vec2-base-960h”)model = Wav2Vec2ForCTC.from_pretrained(“facebook/wav2vec2-base-960h”)I get:ImportError                               Traceback (most recent call last)in3 import soundfile as sf4 import torch----> 5 from transformers import Wav2Vec2ForCTC6 from transformers import Wav2Vec2Tokenizer7ImportError: cannot import name ‘Wav2Vec2ForCTC’ from ‘transformers’ (c:\python\python37\lib\site-packages\transformers_init_.py)How I install/get Wav2Vec2ForCTC and Wav2Vec2Tokenizer ???
2021-02-10T17:14:59Z
This probably means you don’t have the latest version. You should check your version of Transformers withimport transformers
print(transformers.__version__)and if you don’t see at least 4.3.0, you will need to upgrade your install.
2021-02-11T11:01:09Z
I have the same issue with Windows 10.pip install transformers[torch]==4.3import transformersprint(transformers.version)4.3.0from transformers import Wav2Vec2Tokenizer, Wav2Vec2ForCTCTraceback (most recent call last):File “”, line 1, inImportError: cannot import name ‘Wav2Vec2ForCTC’
2021-02-12T07:04:43Z
I had the same issue. I upgraded the transformers version from 4.3.0 to 4.3.2 withpip install transformers==4.3.2and that worked for me. Also, upgrade your PyTorch to its latest version 1.7 withpip install torch==1.7that avoids error while loading pre-trained weights in the next step.
2021-07-15T10:53:49Z
use " from transformers import *" instead of “from transformers import Wav2Vec2Tokenizer, Wav2Vec2ForCTC”