ImportError: There is no such class as speechbrain.lobes.models.huggingface_transformers.wav2vec2.Wav2Vec2

#5
by kmadulka - opened

When I try to run:

classifier = foreign_class(source="speechbrain/emotion-recognition-wav2vec2-IEMOCAP", pymodule_file="custom_interface.py", classname="CustomEncoderWav2vec2Classifier")```
I get the following error:
```ImportError: There is no such class as speechbrain.lobes.models.huggingface_transformers.wav2vec2.Wav2Vec2```

This was not happening a few days ago. Is there anything that changed?
SpeechBrain org

Hello,

Could you please install speechbrain like that: pip install git+https://github.com/speechbrain/speechbrain.git@$develop ?

We are currently moving on a new big release called SpeechBrain 1.0. This new release brings many new features but also some backward incompatible changes (one of them is the path change on wav2vec2). We are currently changing all our HF models to comply with those new changes as the last step before the release in the main branch. I hope you now understand better what is going on.

@Adel-Moumen Unfortunately, I still get the same error even when I install using that command.

SpeechBrain org

Oops I made a small typo, it's not $develop but develop. The full command is the following : pip install git+https://github.com/speechbrain/speechbrain.git@develop.

Please have a look at the following working example on google colab : https://colab.research.google.com/drive/1Oc3Wg-4LSK8CtNiZGiaGPdwqZmGeXamP?usp=sharing

I see that it works in google colab but I am still getting the same error when I run on both my local computer and via databricks. Are there any other dependencies I have to install?

SpeechBrain org

Hmmm could you please show me the output of pip list please?

@Adel-Moumen I just restarted everything and copied and pasted your code and now I am getting the error: No module named 'speechbrain.inference'

SpeechBrain org

Could you please show me the output of pip list ? I suspect that you are still using speechbrain 0.5.X.

@Adel-Moumen
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: hyperpyyaml in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from speechbrain==0.5.16) (1.2.2)
Requirement already satisfied: joblib in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from speechbrain==0.5.16) (1.2.0)
Requirement already satisfied: numpy in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from speechbrain==0.5.16) (1.26.2)
Requirement already satisfied: packaging in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from speechbrain==0.5.16) (23.1)
Requirement already satisfied: scipy in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from speechbrain==0.5.16) (1.11.4)
Requirement already satisfied: sentencepiece in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from speechbrain==0.5.16) (0.2.0)
Requirement already satisfied: torch>=1.9 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from speechbrain==0.5.16) (2.2.0)
Requirement already satisfied: torchaudio in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from speechbrain==0.5.16) (2.2.0)
Requirement already satisfied: tqdm in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from speechbrain==0.5.16) (4.65.0)
Requirement already satisfied: huggingface-hub in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from speechbrain==0.5.16) (0.17.3)
Requirement already satisfied: filelock in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from torch>=1.9->speechbrain==0.5.16) (3.13.1)
Requirement already satisfied: typing-extensions>=4.8.0 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from torch>=1.9->speechbrain==0.5.16) (4.9.0)
Requirement already satisfied: sympy in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from torch>=1.9->speechbrain==0.5.16) (1.12)
Requirement already satisfied: networkx in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from torch>=1.9->speechbrain==0.5.16) (3.1)
Requirement already satisfied: jinja2 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from torch>=1.9->speechbrain==0.5.16) (3.1.2)
Requirement already satisfied: fsspec in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from torch>=1.9->speechbrain==0.5.16) (2023.10.0)
Requirement already satisfied: requests in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from huggingface-hub->speechbrain==0.5.16) (2.31.0)
Requirement already satisfied: pyyaml>=5.1 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from huggingface-hub->speechbrain==0.5.16) (6.0.1)
Requirement already satisfied: ruamel.yaml>=0.17.28 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from hyperpyyaml->speechbrain==0.5.16) (0.18.6)
Requirement already satisfied: ruamel.yaml.clib>=0.2.7 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from ruamel.yaml>=0.17.28->hyperpyyaml->speechbrain==0.5.16) (0.2.8)
Requirement already satisfied: MarkupSafe>=2.0 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from jinja2->torch>=1.9->speechbrain==0.5.16) (2.1.1)
Requirement already satisfied: charset-normalizer<4,>=2 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from requests->huggingface-hub->speechbrain==0.5.16) (2.0.4)
Requirement already satisfied: idna<4,>=2.5 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from requests->huggingface-hub->speechbrain==0.5.16) (3.4)
Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from requests->huggingface-hub->speechbrain==0.5.16) (1.26.18)
Requirement already satisfied: certifi>=2017.4.17 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from requests->huggingface-hub->speechbrain==0.5.16) (2023.11.17)
Requirement already satisfied: mpmath>=0.19 in /Users/kmadulka/anaconda3/lib/python3.11/site-packages (from sympy->torch>=1.9->speechbrain==0.5.16) (1.3.0)

Hey @Adel-Moumen , when will the full speechbrain 1.0 be released? I am currently working on my thesis trying to finetune the model using the IEMOCAP model. So if this change is irreversable, should i waite for this change or should i use the 0.5 version for the time being?

SpeechBrain org

We are trying our best to release it very soon. We will have a meeting today to decide on the release date. I'll let you know but as we've started modifying our HF models then it means it should be very soon (I hope during this week). One note is that if you do use the speechbrain version on our GitHub repo (git clone / pip install -e .) you should be able to run this model properly. There's no performances degradation etc the backward incompatible changes for this model are on the path towards wav2vec2 model. We improved our HF interface.

@Adel-Moumen Any update on this?
I get RuntimeError: Couldn't find appropriate backend to handle uri anger.wav and format None.

SpeechBrain org

Hello @kmadulka ,we should release the new version this week. The problem will disappear by upgrading your speechbrain version to the latest.

TBH, I have some troubles to understand why it does not work on your end to update your speechbrain version to the one used in the google colab (see: https://colab.research.google.com/drive/1Oc3Wg-4LSK8CtNiZGiaGPdwqZmGeXamP?usp=sharing#scrollTo=l8BqY_y_P6cx).

Make sure that you removed your "old" speechbrain version pip uninstall speechbrain --yes and install the latest one like that:

git clone https://github.com/speechbrain/speechbrain.git
pip install -r requirements.txt
pip install -e . 

@Adel-Moumen That unfortunately did not change anything. If I am running on aws databricks, would this change anything? It looks like I have to specify the format in the signal, sr = torchaudio.load(str(path), channels_first=False) within the load_audio function. Is there a way to update this parameter without branching off the repo?

@kmadulka
try installing speechbrain as:
pip install speechbrain==0.5.16

SpeechBrain org

Hello,

Please do: pip install -U speechbrain. We released a new version (1.0.0) that is compatible with all of our HF models.

Sign up or log in to comment