#4260·fairseq

NameError: name 'CriterionType' is not defined [wav2vec2 evaluation using stt.py]

Author: 202015004Created Mar 9, 2022Updated Mar 7, 2026
Labelsquestionneeds triage

NameError: name 'CriterionType' is not defined [wav2vec2 evaluation using stt.py]

I'm still facing this issue. I have tried several techniques. Major attempts are listed below Installation Setup done using following link setup :

Code

from stt import Transcriber transcriber = Transcriber( pretrain_model = 'baseline_trial/Pre-Trained_model/wav2vec_small.pt', finetune_model='outputs/2022-02-27/11-29-48/checkpoints/checkpoint_best.pt', dictionary = 'baseline_trial/dictionary/dict.ltr.txt', lm_type = 'kenlm', lm_lexicon = 'lm/lexicon.txt', lm_model = 'lm/lm.bin',lm_weight = 1.5, word_score = -1, beam_size = 50) hypos = transcriber.transcribe(['/home/speechlab/Desktop/Shreya/TLT_2021/ETLT2021_CAMBRIDGE_EN_baseline/ETLT2021_ETS_EN/audio/dev/1000000000018212-VE648280.wav','/home/speechlab/Desktop/Shreya/TLT_2021/ETLT2021_CAMBRIDGE_EN_baseline/ETLT2021_ETS_EN/audio/dev/1000000000018212-VE654794.wav']) print(hypos)

Error

/home/speechlab/self-supervised-speech-recognition/libs/fairseq/examples/speech_recognition/w2l_decoder.py:42: UserWarning: wav2letter python bindings are required to use this functionality. Please install from https://github.com/facebookresearch/wav2letter/wiki/Python-bindings "wav2letter python bindings are required to use this functionality. Please install from https://github.com/facebookresearch/wav2letter/wiki/Python-bindings" Traceback (most recent call last): File "/home/speechlab/self-supervised-speech-recognition/testing1.py", line 12, in transcriber = Transcriber( pretrain_model = 'baseline_trial/Pre-Trained_model/wav2vec_small.pt', finetune_model='outputs/2022-02-27/11-29-48/checkpoints/checkpoint_best.pt', dictionary = 'baseline_trial/dictionary/dict.ltr.txt', lm_type = 'kenlm', lm_lexicon = 'lm/lexicon.txt', lm_model = 'lm/lm.bin',lm_weight = 1.5, word_score = -1, beam_size = 50) File "/home/speechlab/self-supervised-speech-recognition/stt.py", line 254, in init self.transcribe([sample_audio_path]) File "/home/speechlab/self-supervised-speech-recognition/stt.py", line 359, in transcribe generator = build_generator(args) File "/home/speechlab/self-supervised-speech-recognition/stt.py", line 347, in build_generator return W2lKenLMDecoder(args, task.target_dictionary) File "/home/speechlab/self-supervised-speech-recognition/libs/fairseq/examples/speech_recognition/w2l_decoder.py", line 133, in init super().init(args, tgt_dict) File "/home/speechlab/self-supervised-speech-recognition/libs/fairseq/examples/speech_recognition/w2l_decoder.py", line 56, in init self.criterion_type = CriterionType.CTC NameError: name 'CriterionType' is not defined

What have you tried?

As mentioned in https://github.com/flashlight/flashlight/issues/416#issuecomment-761728139; flashlight is installed, while all the modification mentioned for binding are not similar to the script I received after installation of fairseq

What's your environment?

Source: facebookresearch/fairseq