speechbrain/speechbrain

ModuleNotFoundError: No module named 'speechbrain.pretrained'

pksebben opened this issue · 4 comments

Describe the bug

Have tested on pypi, git@main, and git@develop.

>>> import speechbrain.pretrained
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'speechbrain.pretrained'
>>>

Interestingly, this issue also arises when installing and running https://github.com/cvqluu/simple_diarizer, which uses speechbrain.

this is the whole speechbrain object when imported (minus builtins):

__cached__ :: /home/mlbot/.local/lib/python3.10/site-packages/speechbrain/__pycache__/__init__.cpython-310.pyc
__doc__ ::  Comprehensive speech processing toolkit

__file__ :: /home/mlbot/.local/lib/python3.10/site-packages/speechbrain/__init__.py
__loader__ :: <_frozen_importlib_external.SourceFileLoader object at 0x7a0b872e4fd0>
__name__ :: speechbrain
__package__ :: speechbrain
__path__ :: ['/home/mlbot/.local/lib/python3.10/site-packages/speechbrain']
__spec__ :: ModuleSpec(name='speechbrain', loader=<_frozen_importlib_external.SourceFileLoader object at 0x7a0b872e4fd0>, origin='/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/__init__.py', submodule_search_locations=['/home/mlbot/.local/lib/python3.10/site-packages/speechbrain'])
__version__ :: 1.0.0
alignment :: <module 'speechbrain.alignment' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/alignment/__init__.py'>
augment :: <module 'speechbrain.augment' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/augment/__init__.py'>
core :: <module 'speechbrain.core' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/core.py'>
create_experiment_directory :: <function create_experiment_directory at 0x7a0b872edbd0>
dataio :: <module 'speechbrain.dataio' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/dataio/__init__.py'>
decoders :: <module 'speechbrain.decoders' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/decoders/__init__.py'>
f :: <_io.TextIOWrapper name='/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/version.txt' mode='r' encoding='UTF-8'>
lm :: <module 'speechbrain.lm' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/lm/__init__.py'>
lobes :: <module 'speechbrain.lobes' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/lobes/__init__.py'>
nnet :: <module 'speechbrain.nnet' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/nnet/__init__.py'>
os :: <module 'os' from '/usr/lib/python3.10/os.py'>
parse_arguments :: <function parse_arguments at 0x7a0a29cf1630>
processing :: <module 'speechbrain.processing' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/processing/__init__.py'>
tokenizers :: <module 'speechbrain.tokenizers' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/tokenizers/__init__.py'>
utils :: <module 'speechbrain.utils' from '/home/mlbot/.local/lib/python3.10/site-packages/speechbrain/utils/__init__.py'>
version :: 1.0.0

Expected behaviour

speechbrain.pretrained ought to exist as per the intro docs:

from speechbrain.pretrained import EncoderDecoderASR

asr_model = EncoderDecoderASR.from_hparams(source="speechbrain/asr-conformer-transformerlm-librispeech", savedir="pretrained_models/asr-transformer-transformerlm-librispeech")
asr_model.transcribe_file("speechbrain/asr-conformer-transformerlm-librispeech/example.wav")

To Reproduce

No response

Environment Details

on Python 3.10.12

Relevant Log Output

No response

Additional Context

No response

maybe the version problem, the usage can refer to :

from speechbrain.inference.interfaces import foreign_class
asr_model = foreign_class(source="speechbrain/asr-wav2vec2-ctc-aishell",  pymodule_file="custom_interface.py", classname="CustomEncoderDecoderASR")
asr_model.transcribe_file("speechbrain/asr-wav2vec2-ctc-aishell/example.wav")

in version 1.0.0
here does not exist "pretained" package

This is expected due to the move to SpeechBrain 1.0 which introduced a breaking change on the inference API. See the update notes: https://colab.research.google.com/drive/1IEPfKRuvJRSjoxu22GZhb3czfVHsAy0s?usp=sharing

This should be a relatively straightforward change to update to the new API. Alternatively, if you must, you can pin your SB dependency to 0.5.16 in your environment, which should be the last version to have the pretrained module.

Maybe time to update the README. As someone trying to use this project for the first time, it's not straightforward to make the update as suggested. Thank you.

Yeah, the README is what got me here as well. Having that out-of-step with the current version caused me a few hours of heisenbug-chasing, and I can imagine that's going to be a common experience.