kadirnar / whisper-plus

WhisperPlus: Faster, Smarter, and More Capable 🚀
Apache License 2.0
1.73k stars 137 forks source link

Issue: diarization = self.diarization_pipeline( TypeError: 'NoneType' object is not callable #87

Closed PiotrEsse closed 6 months ago

PiotrEsse commented 6 months ago

I am getting this error. Should I put somewhere HF auth token?

Could not download 'pyannote/speaker-diarization' pipeline.
It might be because the pipeline is private or gated so make
sure to authenticate. Visit https://hf.co/settings/tokens to
create your access token and retry with:

   >>> Pipeline.from_pretrained('pyannote/speaker-diarization',
   ...                          use_auth_token=YOUR_AUTH_TOKEN)

If this still does not work, it might be because the pipeline is gated:
visit https://hf.co/pyannote/speaker-diarization to accept the user conditions.
Traceback (most recent call last):
  File "/home/piotr/WhisperPlus/Tutorial/Diarization.py", line 18, in <module>
    output_text = pipeline(audio_path, num_speakers=2, min_speaker=1, max_speaker=2)
  File "/home/piotr/anaconda3/envs/WhisperPlus308/lib/python3.8/site-packages/whisperplus/pipelines/whisper_diarize.py", line 104, in __call__
    diarization = self.diarization_pipeline(
TypeError: 'NoneType' object is not callable
kadirnar commented 6 months ago

You must use the V3 model and confirm it. image

And run this you have to enter token_id.

pip install -U "huggingface_hub[cli]"
huggingface-cli login
PiotrEsse commented 6 months ago

Thank You. I follow your instruction but still getting this error:

(WhisperPlus38) piotr@Legion7:~/WhisperPlus/Tutorial$ huggingface-cli login

    _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|
    _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|
    _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|
    _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|
    _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|

    A token is already saved on your machine. Run `huggingface-cli whoami` to get more information or `huggingface-cli logout` if you want to log out.
    Setting a new token will erase the existing one.
    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Enter your token (input will not be visible):
Add token as git credential? (Y/n) y
Token is valid (permission: write).
Your token has been saved in your configured git credential helpers (store).
Your token has been saved to /home/piotr/.cache/huggingface/token
Login successful
(WhisperPlus38) piotr@Legion7:~/WhisperPlus/Tutorial$ python diarizoation.py
2024-05-07 08:04:06,861 - WARNING - /home/piotr/anaconda3/envs/WhisperPlus38/lib/python3.8/site-packages/pyannote/audio/core/io.py:43: UserWarning: torchaudio._backend.set_audio_backend has been deprecated. With dispatcher enabled, this function is no-op. You can remove the function call.
  torchaudio.set_audio_backend("soundfile")

2024-05-07 08:04:09,278 - ERROR - An error occurred: __init__: could not find match for ^\w+\W
Special tokens have been added in the vocabulary, make sure the associated word embeddings are fine-tuned or trained.

Could not download 'pyannote/speaker-diarization' pipeline.
It might be because the pipeline is private or gated so make
sure to authenticate. Visit https://hf.co/settings/tokens to
create your access token and retry with:

   >>> Pipeline.from_pretrained('pyannote/speaker-diarization',
   ...                          use_auth_token=YOUR_AUTH_TOKEN)

If this still does not work, it might be because the pipeline is gated:
visit https://hf.co/pyannote/speaker-diarization to accept the user conditions.
Traceback (most recent call last):
  File "diarizoation.py", line 18, in <module>
    output_text = pipeline(audio_path, num_speakers=2, min_speaker=1, max_speaker=2)
  File "/home/piotr/anaconda3/envs/WhisperPlus38/lib/python3.8/site-packages/whisperplus/pipelines/whisper_diarize.py", line 102, in __call__
    inputs, diarizer_inputs = self.preprocess(inputs)
  File "/home/piotr/anaconda3/envs/WhisperPlus38/lib/python3.8/site-packages/whisperplus/pipelines/whisper_diarize.py", line 225, in preprocess
    raise ValueError(f"We expect a numpy ndarray as input, got `{type(inputs)}`")
ValueError: We expect a numpy ndarray as input, got `<class 'NoneType'>`
PiotrEsse commented 6 months ago

Ive enabled all pyannote models in huggingface. Still the error persist. Maybe I should store HF token in a .env file?

kadirnar commented 6 months ago

This is not about the model. Didn't download the .mp3 file. https://github.com/kadirnar/whisper-plus/issues/89

2024-05-07 08:04:09,278 - ERROR - An error occurred: __init__: could not find match for ^\w+\W
GuyPaddock commented 4 months ago

@kadirnar I'm still seeing this behavior.

[youtube] Extracting URL: https://www.youtube.com/watch?v=mRB14sFHw2E
[youtube] mRB14sFHw2E: Downloading webpage
WARNING: [youtube] Webpage contains broken formats (poToken experiment detected). Ignoring initial player response
[youtube] mRB14sFHw2E: Downloading ios player API JSON
[youtube] mRB14sFHw2E: Downloading player 1f8742dc
[youtube] mRB14sFHw2E: Downloading web player API JSON
[youtube] mRB14sFHw2E: Downloading m3u8 information
[info] mRB14sFHw2E: Downloading 1 format(s): 251
[download] Destination: test.webm
[download] 100% of  451.21KiB in 00:00:00 at 2.45MiB/s
[ExtractAudio] Destination: test.mp3
Deleting original file test.webm (pass -k to keep)
2024-07-27 15:14:53,911 - INFO - Downloaded test.mp3 as MP3

Could not download 'pyannote/speaker-diarization-3.1' pipeline.
It might be because the pipeline is private or gated so make
sure to authenticate. Visit https://hf.co/settings/tokens to
create your access token and retry with:

   >>> Pipeline.from_pretrained('pyannote/speaker-diarization-3.1',
   ...                          use_auth_token=YOUR_AUTH_TOKEN)

If this still does not work, it might be because the pipeline is gated:
visit https://hf.co/pyannote/speaker-diarization-3.1 to accept the user conditions.
Traceback (most recent call last):
  File "/mnt/array1/home/guyep/playground/whisper-plus/diarize_yt.py", line 15, in <module>
    output_text = pipeline(audio_path, num_speakers=2, min_speaker=1, max_speaker=2)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/array1/home/guyep/miniconda3/envs/whisper-plus/lib/python3.12/site-packages/whisperplus/pipelines/whisper_diarize.py", line 104, in __call__
    diarization = self.diarization_pipeline(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable

I have tried tokens with fine-grained permissions, read-only, and full write access. I have also accepted the user conditions.

GuyPaddock commented 4 months ago

As a workaround for the issue, I was able to create a sample script file from the documentation on py_annotate that was able to cache the model:

# instantiate the pipeline
from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained(
  "pyannote/speaker-diarization-3.1",
  use_auth_token="YOUR TOKEN HERE")

Just adding the token into the code and running the script was enough.

It seems like the bug is that Whisper Plus cannot download the model using the token that was cached via the huggingface-cli login command.