Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use pyannote speaker diarization without hugginface token or is there any way to download and use the model do do diarization. #1410

Closed
shanky100 opened this issue Jun 20, 2023 · 22 comments
Labels

Comments

@shanky100
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context about the feature request here.

@github-actions
Copy link

Thank you for your issue.
We found the following entries in the FAQ which you may find helpful:

Feel free to close this issue if you found an answer in the FAQ.

If your issue is a feature request, please read this first and update your request accordingly, if needed.

If your issue is a bug report, please provide a minimum reproducible example as a link to a self-contained Google Colab notebook containing everthing needed to reproduce the bug:

  • installation
  • data preparation
  • model download
  • etc.

Providing an MRE will increase your chance of getting an answer from the community (either maintainers or other power users).

We also offer paid scientific consulting services around speaker diarization (and speech processing in general).

This is an automated reply, generated by FAQtory

@sheetalmathur
Copy link

I would also like to know the same, can i use the pyannote without hugging face model?

@hbredin
Copy link
Member

hbredin commented Jun 20, 2023

Please read the FAQ. The FAQtory bot did a good job pointing to the answer...

@nlp03
Copy link

nlp03 commented Jun 20, 2023

I am also interested in understanding whether it is possible to utilize Pyannote independently, without relying on Hugging Face model keys.

@shanky100
Copy link
Author

I see that the model is gated, is it mandatory to have the huggingface token in order to use these models or this model is developed and hosted by hugginface.
Also what information it collects in order to provide access.

It would be helpful, if I could get few answers due to data privacy issues and some access related issues faced in accessing huggingface.

@LouieBHLu
Copy link

In the FAQ, it only refers to the offline usage of segmentation I guess. What about diarization then?

@ExtReMLapin
Copy link

ExtReMLapin commented Aug 7, 2023

The FAQ didn't really help me, what I did on my side it I used the token and specified a custom download path, which later will be working without the token, for example :

os.environ["HF_DATASETS_OFFLINE"] = "1"
os.environ['TRANSFORMERS_CACHE'] = diarization_path
os.environ['TORCH_HOME'] = diarization_path
os.environ['HF_HOME'] = diarization_path
os.environ['PYANNOTE_CACHE'] = diarization_path

then turn all the sym links into real files and it should work, the offline tutorial thing was unreadable so I did this and it works like a charm

@mllife
Copy link

mllife commented Aug 10, 2023

os.environ["HF_DATASETS_OFFLINE"] = "1"
os.environ['TRANSFORMERS_CACHE'] = diarization_path
os.environ['TORCH_HOME'] = diarization_path
os.environ['HF_HOME'] = diarization_path
os.environ['PYANNOTE_CACHE'] = diarization_path

can you shed some more details on the code changes and files placement you did?

@ExtReMLapin , how to convert symlink into files

@ExtReMLapin
Copy link

ExtReMLapin commented Aug 10, 2023

What will happen is the first time you load it using your token it will download it to the diarization_path path, the next time, you should be able to plug out your ethernet cable and it will auto-download it because it will find it in the cache folder. This way :

diarize_pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization@2c6a571d14c3794623b098a065ff95fa22da7f25")

From memory i got the 2c6a571d14c3794623b098a065ff95fa22da7f25 by manually exploring the diarization_path variable value (which ends up just being a absolute path inside my code folder) and it was just the folder name.

I'm leaving my house in few mins to go to the office, once I get here i'll give you more details


To convert symlink into files on windows just copy/paste lol it auto turns them into real files
I had to do this because of code redistribution

@ExtReMLapin
Copy link

This is (one of)) the folder I end up with after my changes and I load it with the code posted above.

image

Please note the snapshot id in the path that I used in the function in my previous message

@mllife
Copy link

mllife commented Aug 10, 2023

@ExtReMLapin ,
I download all the files and converted them to actual files from symlinks. But, still

diarization_model = Pipeline.from_pretrained(
    checkpoint_path="./diarization_model/models--pyannote--speaker-diarization/snapshots/2c6a571d14c3794623b098a065ff95fa22da7f25/"
)

giving error

Traceback (most recent call last):
  File "/Users/xXOL/Projects/annotations/check_pyannote_offline.py", line 18, in <module>
    diarization_model = Pipeline.from_pretrained(
  File "/Users/xXOL/Projects/annotations/venv/lib/python3.8/site-packages/pyannote/audio/core/pipeline.py", line 88, in from_pretrained
    config_yml = hf_hub_download(
  File "/Users/xXOL/Projects/annotations/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 110, in _inner_fn
    validate_repo_id(arg_value)
  File "/Users/xXOL/Projects/annotations/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 158, in validate_repo_id
    raise HFValidationError(
huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': './diarization_model/models--pyannote--speaker-diarization/snapshots/2c6a571d14c3794623b098a065ff95fa22da7f25/'. Use `repo_type` argument if needed.

@mllife
Copy link

mllife commented Aug 11, 2023

@ExtReMLapin , can you take a look my previous comment

@mllife
Copy link

mllife commented Aug 11, 2023

@ExtReMLapin model files are now loading from offline cache after I added the env vars. but I still have to use "use_auth_token" in the code.
what changes to do in the code?

  device = "cuda" if torch.cuda.is_available() else "cpu"
  # TODO - update this
  diarization_model = Pipeline.from_pretrained(
      checkpoint_path="pyannote/speaker-diarization@2c6a571d14c3794623b098a065ff95fa22da7f25",
      use_auth_token="hf_xxxxxxxxxxxxx",
  )
  diarization_model = diarization_model.to(torch.device(device))

@ExtReMLapin
Copy link

I got out of bed, brain's booting.

Right now I don't see why it could not work on your end can you show the full error stack ?

@mllife
Copy link

mllife commented Aug 11, 2023

@ExtReMLapin , this is the full error

Traceback (most recent call last):
  File "/Users/xXOL/Projects/annotations/check_pyannote_offline.py", line 18, in <module>
    diarization_model = Pipeline.from_pretrained(
  File "/Users/xXOL/Projects/annotations/venv/lib/python3.8/site-packages/pyannote/audio/core/pipeline.py", line 88, in from_pretrained
    config_yml = hf_hub_download(
  File "/Users/xXOL/Projects/annotations/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 110, in _inner_fn
    validate_repo_id(arg_value)
  File "/Users/xXOL/Projects/annotations/venv/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 158, in validate_repo_id
    raise HFValidationError(
huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': './diarization_model/models--pyannote--speaker-diarization/snapshots/2c6a571d14c3794623b098a065ff95fa22da7f25/'. Use `repo_type` argument if needed.

@ExtReMLapin
Copy link

The error you posted shows your line of code isn't the one from this message #1410 (comment)

Use the one from my message

@mllife
Copy link

mllife commented Aug 11, 2023

The model loaded is None. If I don't add "use_auth_token"
Screenshot 2023-08-11 at 4 55 40 PM
Screenshot 2023-08-11 at 4 58 17 PM
@ExtReMLapin , can you share full code snippet of how you are processing a sample.wav file?

@ExtReMLapin
Copy link

Whole code is at the office and models are at the office, and I got this day off. So i'll be able to help next week

@mllife
Copy link

mllife commented Aug 11, 2023

thanks, will wait for the update.

@ExtReMLapin
Copy link

Alright, this is how my localized folder looks

image

image

In this folder there used to be symbolic links, copy/paste managed to turn them into real files.

my pip freeze :

transformers @ git+https://github.com/huggingface/transformers.git@460b844360131c99d3dd4dbd9c08545ea2e6ac9e

pyannote.algorithms==0.8
pyannote.audio==2.1.1
pyannote.core==5.0.0
pyannote.database==5.0.0
pyannote.metrics==3.2.1
pyannote.parser==0.8
pyannote.pipeline==2.3

As for the code :

import torch
from pyannote.audio import Pipeline

import numpy as np
diarize_pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization@2c6a571d14c3794623b098a065ff95fa22da7f25")

if torch.cuda.is_available():
    diarize_pipeline = diarize_pipeline.to("cuda")

def diarize(audio_path, num_spk=None):
    
    diarization = diarize_pipeline(audio_path, num_speakers=num_spk)
    diarization_list = list()
    for turn, _, speaker in diarization.itertracks(yield_label=True):
        diarization_list.append([turn.start, turn.end, speaker])
    print(diarization_list)
    return diarization_list

and in another file included sooner :

import os
#load config and if path is relative path, convert to absolute path
import json

with open("config.json") as f:
    data_json = json.load(f)



diarization_path = data_json["diarization_path"]
if not os.path.isabs(diarization_path):
    diarization_path = os.path.abspath(diarization_path) + "/"
    




os.environ["HF_DATASETS_OFFLINE"] = "1"
os.environ['TRANSFORMERS_CACHE'] = diarization_path
os.environ['TORCH_HOME'] = diarization_path
os.environ['HF_HOME'] = diarization_path
os.environ['PYANNOTE_CACHE'] = diarization_path

@mllife
Copy link

mllife commented Aug 24, 2023

@ExtReMLapin , thanks for your detailed response.
But i am unable to install the modules required due to conflicts.

The conflict is caused by:
    The user requested pyannote.core==5.0.0
    pyannote-algorithms 0.8 depends on pyannote.core>=1.3.1
    pyannote-audio 2.1.1 depends on pyannote.core<5.0 and >=4.4

If I am changing anything, then I am getting

  ERROR: Failed building wheel for hmmlearn
  Running setup.py clean for hmmlearn
Failed to build hmmlearn

Can you tell about the python version being used? or anything else I can do?

With the setup python 3.10 I got
pip list | grep 'pyannote'

pyannote.audio          2.1.1
pyannote.core           5.0.0
pyannote.database       5.0.1
pyannote.metrics        3.2.1
pyannote.pipeline       2.3

Copy link

stale bot commented Feb 20, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Feb 20, 2024
@stale stale bot closed this as completed Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants