mailong25 / self-supervised-speech-recognition

speech to text with self-supervised learning based on wav2vec 2.0 framework
379 stars 115 forks source link

Import stt is not working! #46

Open gauravgund opened 3 years ago

gauravgund commented 3 years ago

Hi @mailong25 @SenriYoshikawa ,

I am able to train acoustic model and Kenlm but when i am trying to import stt for transcribing, I am getting the following error in the self-supervised-speech-recognition directory.

Error


ImportError Traceback (most recent call last)

in () 1 get_ipython().magic('cd /content/self-supervised-speech-recognition') ----> 2 import stt /content/self-supervised-speech-recognition/stt.py in () 7 import numpy as np 8 import torch ----> 9 from fairseq import checkpoint_utils, options, progress_bar, tasks, utils 10 from fairseq.data.data_utils import post_process 11 from fairseq.logging.meters import StopwatchMeter, TimeMeter ImportError: cannot import name 'checkpoint_utils' from 'fairseq' (unknown location) I tried importing fairseq in the directory i.e. /content/self-supervised-speech-recognition/libs/fairseq and it is working fine. Kindly help me with the work-around for this conflict in the directories. Regards
mailong25 commented 3 years ago

Are you using the right fairseq git checkpoint?

git clone https://github.com/pytorch/fairseq.git
cd fairseq
git checkout c8a0659be5cdc15caa102d5bbf72b872567c4859
pip install --editable ./
cd ..
gauravgund commented 3 years ago

Yes

mailong25 commented 3 years ago

You can look at some threads here: https://stackoverflow.com/questions/58585690/python-cannot-import-unknown-location https://stackoverflow.com/questions/63728242/importerror-cannot-import-name-unknown-location

gauravgund commented 3 years ago

I am looking at the folder structure:

fairseq has fairseq folder again which has this checkpoint_utils.py file. Is it the expected behaviour?

On Wed, 31 Mar 2021 at 6:31 PM, Long Mai @.***> wrote:

You can look at some threads here:

https://stackoverflow.com/questions/58585690/python-cannot-import-unknown-location

https://stackoverflow.com/questions/63728242/importerror-cannot-import-name-unknown-location

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mailong25/self-supervised-speech-recognition/issues/46#issuecomment-811049144, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALBKX6TICRVRAOTZXYZNVE3TGMMKHANCNFSM42EI7GAQ .

mailong25 commented 3 years ago

Make sure the followings are correct:

gauravgund commented 3 years ago

hi,

I have installed Fairseq successfully! 2) I can't import Fairseq from any directory but only when i am inside fairseq directory 3) I am calling "from stt import Transcriber" under "self-supervised-speech-recognition" directory but i am getting the error """" ImportError: cannot import name 'Transcriber' from 'stt' (/content/self-supervised-speech-recognition/stt.py)"""" 4) Note that i have to make changes to the stt.py files which are as follows:

_from fairseq.fairseq import checkpoint_utils, options, progress_bar, tasks, utils from fairseq.fairseq.data.data_utils import postprocess from fairseq.fairseq.logging.meters import StopwatchMeter, TimeMeter

This is because when i am following your instructions, the folder structure is fairseq>fairseq>checkpoint_utils and so on.

image

Could you please check my script:

https://github.com/gauravgund/gauravgund/blob/master/wav2vec_fairseq__finetuning.ipynb

luiyen commented 3 years ago

@mailong25 @gauravgund got the same issue, but it works fine after restarted. We can close it now.