m-bain / whisperX

WhisperX: Automatic Speech Recognition with Word-level Timestamps (& Diarization)
BSD 2-Clause "Simplified" License
11.59k stars 1.23k forks source link

`numpy==2.0.0` breaks model loading #826

Open YoungPhlo opened 3 months ago

YoungPhlo commented 3 months ago

Command: whisperx "audio/test.mp3" --model "large-v2" --language "en"

Error:

Traceback (most recent call last):
  File "~/transcription/whisperX/venv/bin/whisperx", line 5, in <module>
    from whisperx.transcribe import cli
  File "~/transcription/whisperX/venv/lib/python3.10/site-packages/whisperx/__init__.py", line 1, in <module>
    from .transcribe import load_model
  File "~/transcription/whisperX/venv/lib/python3.10/site-packages/whisperx/transcribe.py", line 10, in <module>
    from .asr import load_model
  File "~/transcription/whisperX/venv/lib/python3.10/site-packages/whisperx/asr.py", line 13, in <module>
    from .vad import load_vad_model, merge_chunks
  File "~/transcription/whisperX/venv/lib/python3.10/site-packages/whisperx/vad.py", line 9, in <module>
    from pyannote.audio import Model
  File "~/transcription/whisperX/venv/lib/python3.10/site-packages/pyannote/audio/__init__.py", line 29, in <module>
    from .core.inference import Inference
  File "~/transcription/whisperX/venv/lib/python3.10/site-packages/pyannote/audio/core/inference.py", line 49, in <module>
    class Inference(BaseInference):
  File "~/transcription/whisperX/venv/lib/python3.10/site-packages/pyannote/audio/core/inference.py", line 533, in Inference
    missing: float = np.NaN,
  File "~/transcription/whisperX/venv/lib/python3.10/site-packages/numpy/__init__.py", line 397, in __getattr__
    raise AttributeError(
AttributeError: `np.NaN` was removed in the NumPy 2.0 release. Use `np.nan` instead.. Did you mean: 'nan'?

ran pip install numpy==1.26.4

Collecting numpy==1.26.4
  Using cached numpy-1.26.4-cp310-cp310-macosx_11_0_arm64.whl.metadata (61 kB)
Using cached numpy-1.26.4-cp310-cp310-macosx_11_0_arm64.whl (14.0 MB)
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 2.0.0
    Uninstalling numpy-2.0.0:
      Successfully uninstalled numpy-2.0.0
Successfully installed numpy-1.26.4

and it loaded the model on the next run.

Maybe it's just me, here are my specs:

- Operating System
ProductName:        macOS
ProductVersion:     14.1
BuildVersion:       23B2073
Kernel:         23.1.0

- Environment
zsh:        5.9 (x86_64-apple-darwin23.0)
Homebrew:   4.3.5
Python:     3.10.14
andbas commented 3 months ago

same thing, thanks for a fix

justinwlin commented 3 months ago

Same thing here - was wondering what was breaking. thx for the fix

camille-lnrs commented 3 months ago

Same here!

camille-lnrs commented 3 months ago

Hi everyone, I found an alternative solution for importing (I don't know if your problems were further). While installing whisperx 3.1.5 you install latest version of numpy that is 2x. However, the both of them are not compatible which makes importations crash. If you uninstall/downgrade numpy after importer whisperx and force a new installation of numpy1.26 it works !

MahmoudAshraf97 commented 2 months ago

You can also use pip install pyannote.audio>==3.3.1 if you need to use numpy>=2.0.0