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

Bug: Voice activity detection import fails #146

Open
900miles opened this issue Aug 15, 2024 · 6 comments
Open

Bug: Voice activity detection import fails #146

900miles opened this issue Aug 15, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@900miles
Copy link
Collaborator

900miles commented Aug 15, 2024

Description

When running the voice activity detection tutorial on google colab (possibly other environments as well, but I've only tested on colab so far), I get a ValidationError when importing the voice activity detection module.

Specifically the offending line is:

from senselab.audio.tasks.voice_activity_detection import detect_human_voice_activity_in_audios

Steps to Reproduce

Open the voice activity detection tutorial in google colab. Add a !pip install senselab to the top and run.

Expected Results

The tutorial should install senselab and import the modules without error.

Actual Results

During the imports code block:

ValidationError                           Traceback (most recent call last)

[<ipython-input-2-149eefe7e14a>](https://localhost:8080/#) in <cell line: 5>()
      3 
      4 from senselab.audio.data_structures.audio import Audio
----> 5 from senselab.audio.tasks.voice_activity_detection import detect_human_voice_activity_in_audios
      6 from senselab.utils.data_structures.model import PyannoteAudioModel
      7 from senselab.utils.data_structures.device import DeviceType

5 frames

[/usr/local/lib/python3.10/dist-packages/senselab/audio/tasks/voice_activity_detection/__init__.py](https://localhost:8080/#) in <module>
      1 """.. include:: ./doc.md"""  # noqa: D415
      2 
----> 3 from .api import detect_human_voice_activity_in_audios  # noqa: F401

[/usr/local/lib/python3.10/dist-packages/senselab/audio/tasks/voice_activity_detection/api.py](https://localhost:8080/#) in <module>
      6 
      7 from senselab.audio.data_structures.audio import Audio
----> 8 from senselab.audio.tasks.speaker_diarization.pyannote import diarize_audios_with_pyannote
      9 from senselab.utils.data_structures.device import DeviceType
     10 from senselab.utils.data_structures.model import PyannoteAudioModel, SenselabModel

[/usr/local/lib/python3.10/dist-packages/senselab/audio/tasks/speaker_diarization/__init__.py](https://localhost:8080/#) in <module>
      1 """.. include:: ./doc.md"""  # noqa: D415
      2 
----> 3 from .api import diarize_audios  # noqa: F401

[/usr/local/lib/python3.10/dist-packages/senselab/audio/tasks/speaker_diarization/api.py](https://localhost:8080/#) in <module>
      9 
     10 from senselab.audio.data_structures.audio import Audio
---> 11 from senselab.audio.tasks.speaker_diarization.pyannote import diarize_audios_with_pyannote
     12 from senselab.utils.data_structures.device import DeviceType
     13 from senselab.utils.data_structures.model import PyannoteAudioModel, SenselabModel

[/usr/local/lib/python3.10/dist-packages/senselab/audio/tasks/speaker_diarization/pyannote.py](https://localhost:8080/#) in <module>
     49 def diarize_audios_with_pyannote(
     50     audios: List[Audio],
---> 51     model: PyannoteAudioModel = PyannoteAudioModel(path_or_uri="pyannote/speaker-diarization-3.1", revision="main"),
     52     device: Optional[DeviceType] = None,
     53     num_speakers: Optional[int] = None,

[/usr/local/lib/python3.10/dist-packages/pydantic/main.py](https://localhost:8080/#) in __init__(self, **data)
    191         # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    192         __tracebackhide__ = True
--> 193         self.__pydantic_validator__.validate_python(data, self_instance=self)
    194 
    195     # The following line sets a flag that we use to determine when `__init__` gets overridden by the user

ValidationError: 1 validation error for PyannoteAudioModel
revision
  Value error, path_or_uri (pyannote/speaker-diarization-3.1) or specified revision (main) is not a valid Hugging Face model [type=value_error, input_value='main', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/value_error

Additional Notes

No response

@900miles 900miles added bug Something isn't working documentation Improvements or additions to documentation and removed documentation Improvements or additions to documentation labels Aug 15, 2024
@900miles 900miles changed the title Bug: Voice activity detection tutorial doesn't work Bug: Voice activity detection import fails Aug 15, 2024
@fabiocat93
Copy link
Collaborator

@900miles nice catch! I think that the issue here is that some huggingface models (e.g., pyannote/speaker-diarization-3.1) require the user to accept some conditions before you can use them. A potential solution to this make be adding something like this:

"Before start testing with our default model by pyannote-audio, we will ask you to:

from huggingface_hub import notebook_login
notebook_login()

@900miles
Copy link
Collaborator Author

That makes sense and I think is a good solution. However we should raise that error only when the user attempts to run the model, not during import. During import the model isn't specified, so having this error could be confusing. Especially if the user wants to use a model other than pyannote

@fabiocat93
Copy link
Collaborator

That makes sense and I think is a good solution. However we should raise that error only when the user attempts to run the model, not during import. During import the model isn't specified, so having this error could be confusing. Especially if the user wants to use a model other than pyannote

I definitely agree in principle. i guess that the error is raised because the code tries to connect to the hub to check if the model exists and since the user is not authorized to use it, it's not even authorized to know... ideas on how to solve this?

@900miles
Copy link
Collaborator Author

900miles commented Oct 6, 2024

Bump on this. It also occurs when running from senselab.audio.tasks.speaker_diarization import diarize_audios. Why is the code loading a model during import?

@900miles
Copy link
Collaborator Author

900miles commented Oct 6, 2024

Also the proposed solution

from huggingface_hub import notebook_login
notebook_login()

doesn't work in all cases, because you can't run notebook_login() outside of a notebook file.

@fabiocat93
Copy link
Collaborator

@900miles You need to export your huggingface token in your environment variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants