{"id":2675,"library":"pyannote-pipeline","title":"pyannote-pipeline","description":"pyannote-pipeline is a component of the pyannote.audio open-source toolkit, specializing in tunable and state-of-the-art pipelines for speaker diarization. Built on the PyTorch machine learning framework, it enables tasks such as speaker segmentation, embedding, and clustering. The library is actively maintained, with its current version 4.0.0 reflecting continuous development and integration within the broader pyannote.audio ecosystem.","status":"active","version":"4.0.0","language":"en","source_language":"en","source_url":"https://github.com/pyannote/pyannote-pipeline","tags":["audio processing","speaker diarization","machine learning","pytorch","pipelines","speech processing"],"install":[{"cmd":"pip install pyannote.audio","lang":"bash","label":"Recommended installation (includes pipelines)"}],"dependencies":[{"reason":"Core library that provides the audio processing functionalities and models.","package":"pyannote.audio"},{"reason":"Underlying machine learning framework for neural network operations.","package":"torch"},{"reason":"Required for downloading and loading pretrained models and pipelines from Hugging Face.","package":"huggingface_hub"},{"reason":"External dependency for audio decoding and processing (must be installed separately on the system).","package":"ffmpeg","optional":false}],"imports":[{"symbol":"Pipeline","correct":"from pyannote.audio import Pipeline"},{"note":"Optional, for monitoring pipeline progress.","symbol":"ProgressHook","correct":"from pyannote.audio.pipelines.utils.hook import ProgressHook"}],"quickstart":{"code":"import os\nfrom pyannote.audio import Pipeline\n\n# Ensure you have a Hugging Face access token set as an environment variable\n# and have accepted user conditions for 'pyannote/speaker-diarization-community-1'\n# on hf.co/pyannote/speaker-diarization-community-1\nhf_token = os.environ.get('HUGGINGFACE_ACCESS_TOKEN', '')\nif not hf_token:\n    print(\"Error: HUGGINGFACE_ACCESS_TOKEN environment variable not set.\")\n    print(\"Please create a token at hf.co/settings/tokens and set it.\")\n    exit()\n\n# Instantiate a pretrained speaker diarization pipeline\ntry:\n    pipeline = Pipeline.from_pretrained(\n        \"pyannote/speaker-diarization-community-1\", \n        token=hf_token\n    )\nexcept Exception as e:\n    print(f\"Failed to load pipeline: {e}\")\n    print(\"Make sure your Hugging Face token is valid and you've accepted user conditions.\")\n    exit()\n\n# Example: Apply the pipeline to an audio file (replace 'audio.wav' with your path)\n# For demonstration, we'll simulate a file path.\n# In a real scenario, you would have 'audio.wav' present.\naudio_file_path = \"dummy_audio.wav\" # Replace with actual audio file path\n\n# This part of the code is illustrative as 'dummy_audio.wav' won't exist.\n# You would typically pass a real audio file path here.\nprint(f\"Attempting to apply pipeline to {audio_file_path}...\")\n# For actual execution, ensure 'ffmpeg' is installed and 'audio.wav' exists.\n# output = pipeline(audio_file_path)\n# print(\"Diarization results:\")\n# for turn, speaker in output.speaker_diarization:\n#     print(f\"start={turn.start:.1f}s stop={turn.end:.1f}s speaker={speaker}\")\n\nprint(\"Pipeline loaded successfully. To run, replace 'dummy_audio.wav' with your audio file and ensure ffmpeg is installed.\")\nprint(\"Note: The actual application of the pipeline to 'dummy_audio.wav' is commented out as it requires a real audio file and ffmpeg.\")","lang":"python","description":"This quickstart demonstrates how to load a pretrained speaker diarization pipeline from Hugging Face. It highlights the critical need for a Hugging Face access token, stored as an environment variable, and acceptance of the model's user conditions. The example then shows how to instantiate the pipeline and prepare to apply it to an audio file. Note that `ffmpeg` must be installed on your system for audio processing."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or later.","message":"`pyannote.audio` (which includes `pyannote-pipeline`) version 4.0.0 requires Python 3.10 or newer. Older Python versions are no longer supported.","severity":"breaking","affected_versions":"4.0.0 and higher"},{"fix":"Replace `use_auth_token=...` with `token=...` when calling `Pipeline.from_pretrained()`.","message":"The `use_auth_token` argument in `Pipeline.from_pretrained()` has been renamed to `token`.","severity":"breaking","affected_versions":"4.0.0 and higher"},{"fix":"Visit `hf.co/settings/tokens` to create a token, and accept the user conditions for the specific `pyannote` models you intend to use (e.g., `hf.co/pyannote/speaker-diarization-community-1`). Provide the token in your code.","message":"Accessing pretrained pipelines from Hugging Face requires accepting user conditions and providing a Hugging Face access token (e.g., via `token=os.environ.get('HUGGINGFACE_ACCESS_TOKEN')`). Failure to do so will result in authentication errors.","severity":"gotcha","affected_versions":"All versions using Hugging Face models"},{"fix":"Install `ffmpeg` on your system. Refer to `ffmpeg.org/download.html` for installation instructions.","message":"The library relies on `ffmpeg` for audio decoding. `ffmpeg` is an external dependency and must be installed separately on your operating system (it is not installed via pip).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Explicitly set `mono=\"downmix\"` when instantiating `Audio()` for multi-channel audio: `Audio(mono=\"downmix\")`.","message":"In `pyannote.audio` 4.0.0, multi-channel audio is no longer automatically downmixed to mono by default. If your workflow involves `pyannote.audio.core.io.Audio` and expects mono conversion, this behavior has changed.","severity":"breaking","affected_versions":"4.0.0 and higher"},{"fix":"If you use ONNX-based models, ensure you install `onnxruntime` explicitly: `pip install onnxruntime`.","message":"`onnxruntime` is no longer a direct dependency of `pyannote.audio`. If you are using models that rely on ONNX, you will need to install `onnxruntime` manually.","severity":"deprecated","affected_versions":"4.0.0 and higher"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}