self-supervised-speech-recognition icon indicating copy to clipboard operation
self-supervised-speech-recognition copied to clipboard

Import stt is not working!

Open gauravgund opened this issue 4 years ago • 7 comments

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

gauravgund avatar Mar 31 '21 10:03 gauravgund

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 ..

mailong25 avatar Mar 31 '21 12:03 mailong25

Yes

gauravgund avatar Mar 31 '21 12:03 gauravgund

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

mailong25 avatar Mar 31 '21 13:03 mailong25

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 .

gauravgund avatar Mar 31 '21 13:03 gauravgund

Make sure the followings are correct:

  • you install the fairseq correctly, which means you can import the lib from any directory.
  • the fairseq dir is not located in the same directory with stt.py
  • You calling the "from stt import Transcriber" under "self-supervised-speech-recognition" directory.

mailong25 avatar Mar 31 '21 16:03 mailong25

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 post_process 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

gauravgund avatar Mar 31 '21 16:03 gauravgund

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

luiyen avatar Jul 03 '21 12:07 luiyen