facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
30.48k stars 6.41k forks source link

wav2vec 2.0 :ModuleNotFoundError: No module named 'examples.speech_recognition' #5231

Open LBY-bamboo opened 1 year ago

LBY-bamboo commented 1 year ago

❓ Questions and Help

After pre-training and fine-tuning wav2vec2.0, we use the evaluation CTC model, and the error message shows "ModuleNotFoundError: No module named 'examples.speech_recognition'". What is the reason for the error? Is it because wav2letter was not installed successfully? How can I solve this problem?

image

SeunghyunSEO commented 1 year ago

no its not about wav2letter or flashlight installation

it is because you install fairseq in wrong path in this case, you can't import fairseq.examples or fairseq.data

and if you want to decode your model in viterbi (greedy) mode, it does not require cpp decoder installation (flashlight)

LBY-bamboo commented 1 year ago

Thank you for your reply. According to your suggestion, I modified the installation path of fairseq. Then I run " python /data/lby/task/fairseq/examples/speech_recognition/infer.py /data/lby/task/fairseq/examples/wav2vec/fine --task audio_finetuning --nbest 1 --path /data/lby/task/fairseq/outputs/2023-05-23/09-57-25/checkpoints/checkpoint_best.pt --gen-subset $subset --results-path /data/lby/task/fairseq/outputs --w2l-decoder viterbi --word-score -1 --sil-weight 0 --criterion ctc --labels ltr --max-tokens 4000000 --post-process letter" to decode our model in viterbi. Shows an error "NameError: name 'CriterionType' is not defined". I checked the code and found that line 56 is "self.criterion_type = CriterionType.CTC". Then, I traced the source of "CriterionType" and found that line 32 shows "from flashlight.lib.text.decoder import CriterionType". Is this caused by flashlight not being installed successfully?

@.***

From: Seunghyun SEO Date: 2023-07-07 17:12 To: facebookresearch/fairseq CC: LBY-bamboo; Author Subject: Re: [facebookresearch/fairseq] wav2vec 2.0 :ModuleNotFoundError: No module named 'examples.speech_recognition' (Issue #5231) no its not about wav2letter or flashlight installation it is because you install fairseq in wrong way path in this case, you can't import fairseq.examples or fairseq.data and if you want to decode your model in viterbi (greedy) mode, it does not require cpp decoder installation (flashlight) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

SeunghyunSEO commented 1 year ago

in my case, i could fix the import error using

cd /workspace/fairseq &&\
pip install -e . &&\
python setup.py build develop &&\
echo "export PYTHONPATH=$PYTHONPATH:/workspace/fairseq/examples" >> ~/.bashrc
LBY-bamboo commented 1 year ago

Thanks for your reply. According to your suggestion, we updated the fairseq installation path as follows: But running "python /data/lby/task/fairseq/examples/speech_recognition/infer.py /data/lby/task/fairseq/examples/wav2vec/fine --task audio_finetuning --nbest 1 --path /data/lby/task/fairseq/outputs/2023-05-23/09-57-25/checkpoints/checkpoint_best.pt --gen-subset $subset --results-path /data/lby/task/fairseq/outputs --w2l-decoder viterbi --word-score -1 --sil-weight 0 --criterion ctc --labels ltr --max-tokens 4000000 --post-process letter" during decoding. There is still an error showing ""NameError: name 'CriterionType' is not defined". I checked the code and found that line 56 in w2l_decoder.py is "self.criterion_type = CriterionType.CTC". Then, I traced the source of "CriterionType" and found that line 32 shows "from flashlight.lib.text.decoder import CriterionType". Is this caused by flashlight not being installed successfully? @.***

From: Seunghyun SEO Date: 2023-07-13 03:55 To: facebookresearch/fairseq CC: LBY-bamboo; Author Subject: Re: [facebookresearch/fairseq] wav2vec 2.0 :ModuleNotFoundError: No module named 'examples.speech_recognition' (Issue #5231) in my case, i could fix the import error using cd /workspace/fairseq &&\ pip install -e . &&\ python setup.py build develop &&\ echo "export PYTHONPATH=$PYTHONPATH:/workspace/fairseq/examples" >> ~/.bashrc

― Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>