pyannote / pyannote-audio

Neural building blocks for speaker diarization: speech activity detection, speaker change detection, overlapped speech detection, speaker embedding
http://pyannote.github.io
MIT License
5.47k stars 725 forks source link

Add missing requirement for speechbrain #855

Closed zaouk closed 2 years ago

zaouk commented 2 years ago

Describe the bug The speechbrain requirement is still missing, and if we try to instantiate a pyannote/speaker-diarization pipeline we get:

[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyannote.audio import Pipeline
/Users/khaled/anaconda3/envs/pyannote/lib/python3.8/site-packages/pytorch_lightning/core/memory.py:16: LightningDeprecationWarning: `pytorch_lightning.core.memory.get_memory_profile` and `pytorch_lightning.core.memory.get_gpu_memory_map` have been moved to `pytorch_lightning.utilities.memory` since v1.5 and will be removed in v1.7.
  rank_zero_deprecation(
/Users/khaled/anaconda3/envs/pyannote/lib/python3.8/site-packages/pytorch_lightning/core/memory.py:25: LightningDeprecationWarning: `pytorch_lightning.core.memory.LayerSummary` and `pytorch_lightning.core.memory.ModelSummary` have been moved to `pytorch_lightning.utilities.model_summary` since v1.5 and will be removed in v1.7.
  rank_zero_deprecation(
>>> pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/khaled/anaconda3/envs/pyannote/lib/python3.8/site-packages/pyannote/audio/core/pipeline.py", line 98, in from_pretrained
    pipeline = Klass(**config["pipeline"].get("params", {}))
  File "/Users/khaled/anaconda3/envs/pyannote/lib/python3.8/site-packages/pyannote/audio/pipelines/speaker_diarization.py", line 119, in __init__
    self._embedding = PretrainedSpeakerEmbedding(self.embedding, device=emb_device)
  File "/Users/khaled/anaconda3/envs/pyannote/lib/python3.8/site-packages/pyannote/audio/pipelines/speaker_verification.py", line 265, in PretrainedSpeakerEmbedding
    return SpeechBrainPretrainedSpeakerEmbedding(embedding, device=device)
  File "/Users/khaled/anaconda3/envs/pyannote/lib/python3.8/site-packages/pyannote/audio/pipelines/speaker_verification.py", line 81, in __init__
    raise ImportError(
ImportError: 'speechbrain' must be installed to use 'speechbrain/spkrec-ecapa-voxceleb' embeddings. Visit https://speechbrain.github.io for installation instructions.

To Reproduce Steps to reproduce the behavior:

conda activate pyannote
conda install pytorch torchaudio -c pytorch

# pyannote.audio relies on torchaudio's soundfile backend,
# itself relying on libsndfile, sometimes tricky to install.
# This seems to work fine but is provided with no guarantee of success:
conda install numpy cffi
conda install libsndfile=1.0.28 -c conda-forge

pip install https://github.com/pyannote/pyannote-audio/archive/develop.zip

python

then inside the python shell:

from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization")

FIX I fixed this by just calling


pip install speechbrain```

What remains is pinning the version of speechbrain within the requirements file under the `develop` branch.
micahjon commented 2 years ago

@hbredin , I'm still running into this issue with a fresh install of pyannote (using instructions in README). When I call:

pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization")`

I get this error: ImportError: 'speechbrain' must be installed to use 'speechbrain/spkrec-ecapa-voxceleb' embeddings. Visit https://speechbrain.github.io for installation instructions

When I run pip3 install speechbrain, it downgrades torch from 1.12.0 to 1.11.0 and then breaks the torchaudio integration. Any ideas how to fix this?

Thanks a million!

micahjon commented 2 years ago

For anyone else running into this issue, it can be solved by using the prior version of Pytorch (1.11.0), which is compatible with speechbrain: https://pytorch.org/get-started/previous-versions/#v1110

conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3 -c pytorch

Here are the error messages that I was getting before doing this (in case others are googling them).

After pip install speechbrain ...

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchvision 0.13.0 requires torch==1.12.0, but you have torch 1.11.0 which is incompatible.

And when I ran Pipeline.from_pretrained(...) (see above comment), the error message I got was related to torchvision (as expected from the pip error):

/usr/local/envs/pyannote/lib/python3.8/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: /usr/local/envs/pyannote/lib/python3.8/site-packages/torchvision/image.so: undefined symbol: _ZN3c106detail19maybe_wrap_dim_slowEllb
  warn(f"Failed to load image Python extension: {e}")
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from pyannote.audio import Pipeline
  File "/usr/local/envs/pyannote/lib/python3.8/site-packages/pyannote/audio/__init__.py", line 29, in <module>
    from .core.inference import Inference
  File "/usr/local/envs/pyannote/lib/python3.8/site-packages/pyannote/audio/core/inference.py", line 33, in <module>
    from pyannote.audio.core.io import AudioFile
  File "/usr/local/envs/pyannote/lib/python3.8/site-packages/pyannote/audio/core/io.py", line 38, in <module>
    import torchaudio
  File "/usr/local/envs/pyannote/lib/python3.8/site-packages/torchaudio/__init__.py", line 1, in <module>
    from torchaudio import (  # noqa: F401
  File "/usr/local/envs/pyannote/lib/python3.8/site-packages/torchaudio/_extension.py", line 103, in <module>
    _init_extension()
  File "/usr/local/envs/pyannote/lib/python3.8/site-packages/torchaudio/_extension.py", line 88, in _init_extension
    _load_lib("libtorchaudio")
  File "/usr/local/envs/pyannote/lib/python3.8/site-packages/torchaudio/_extension.py", line 51, in _load_lib
    torch.ops.load_library(path)
  File "/usr/local/envs/pyannote/lib/python3.8/site-packages/torch/_ops.py", line 220, in load_library
    ctypes.CDLL(path)
  File "/usr/local/envs/pyannote/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libtorch_cuda_cpp.so: cannot open shared object file: No such file or directory
hbredin commented 2 years ago

Would you mind contributing a PR with an update to the Installation section of the README file?