# Pyannotate pipeline() not working

**URL:** <https://discuss.huggingface.co/t/pyannotate-pipeline-not-working/134508>\
**Category:** Intermediate\
**Created:** [January 6, 2025, 4:04pm UTC](https://discuss.huggingface.co/t/pyannotate-pipeline-not-working/134508 "2025-01-06T16:04:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shantanu2698](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@shantanu2698](https://discuss.huggingface.co/u/shantanu2698)\
**Post date:** [January 6, 2025, 4:04pm UTC](https://discuss.huggingface.co/t/pyannotate-pipeline-not-working/134508/1 "2025-01-06T16:04:01Z")

</div>

I am using pyannotate for speaker diarization on top of Whisper. However, even though I have provided the token credential, the code consistently gets stuck at the `pipeline()` call. This eventually leads to the Colab session disconnecting. The video in question is relatively short, only 11:46 minutes. I have attached the code for your reference.

from pyannote.audio import Pipeline  
wav\_file=“download1.wav”

# Load the pretrained diarization pipeline

pipeline = Pipeline.from\_pretrained(“pyannote/speaker-diarization”, use\_auth\_token=“hf\_xxxxxxxxxxxxxxxxxxx”  
)

# Apply the pipeline to the audio fie

diarization = pipeline(wav\_file) ######this is where code is getting stuck

# Save the diarization output to a file

with open(“diarization.txt”, “w”) as f:  
for turn, \_, speaker in diarization.itertracks(yield\_label=True):  
f.write(f"{turn.start:.2f} - {turn.end:.2f}: Speaker {speaker}\n")

print(“Speaker diarization completed.”)

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [January 6, 2025, 6:02pm UTC](https://discuss.huggingface.co/t/pyannotate-pipeline-not-working/134508/2 "2025-01-06T18:02:22Z")

</div>

I wonder if the Pyannotate settings are wrong…

> [@Issue with Using pyannote/speaker-diarization Gated Model in Colab and API](https://discuss.huggingface.co/t/issue-with-using-pyannote-speaker-diarization-gated-model-in-colab-and-api/134386):
>
> Hi everyone, I’m currently working on my engineering thesis, which involves analyzing speaker diarization for Polish audio files. I’m trying to use the pyannote/speaker-diarization model to perform this task, but I’ve encountered several issues that I haven’t been able to resolve, even after trying various approaches. Here’s a summary of my problem: Access Granted but Model Not Running: I’ve been granted access to the gated model on Hugging Face. However, when I try to use the model through…

---

<div class="post-metadata">

**Author:** ![shantanu2698](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@shantanu2698](https://discuss.huggingface.co/u/shantanu2698)\
**Post date:** [January 8, 2025, 10:20am UTC](https://discuss.huggingface.co/t/pyannotate-pipeline-not-working/134508/3 "2025-01-08T10:20:46Z")

</div>

I am still stuck at this point. Even though I have been granted model permission, it’s not running and keeps on getting stuck at pipeline(“download1.wav”). I have accepted the user conditions as well. I need urgent help

---

<div class="post-metadata">

**Author:** ![shantanu2698](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@shantanu2698](https://discuss.huggingface.co/u/shantanu2698)\
**Post date:** [January 8, 2025, 10:21am UTC](https://discuss.huggingface.co/t/pyannotate-pipeline-not-working/134508/4 "2025-01-08T10:21:59Z")

</div>

Thanks for the reply @John6666 . But the issue remains the same, Even though I have followed all the steps mentioned on the shared post.

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [January 8, 2025, 12:51pm UTC](https://discuss.huggingface.co/t/pyannotate-pipeline-not-working/134508/5 "2025-01-08T12:51:15Z")

</div>

I thought it was possible that your GPU wasn’t being used. How about this?

```py
# https://github.com/pyannote/pyannote-audio
from pyannote.audio import Pipeline
import torch

hf_token = "hf_xxxxxxxxxxxxxxxxxxx"
device = "cuda" if torch.cuda.is_available() else "cpu"
wav_file="download1.wav"

#Load the pretrained diarization pipeline
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization", use_auth_token=hf_token).to(device) # send pipeline to GPU (when available)
# pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization", device_map="auto", use_auth_token=hf_token) # if your GPU is weak... ensure "pip install -U accelerate" before use it

# Apply the pipeline to the audio fie
diarization = pipeline(wav_file) ######this is where code is getting stuck

#Save the diarization output to a file
with open("diarization.txt", "w") as f:
    for turn, _, speaker in diarization.itertracks(yield_label=True):
       f.write(f"{turn.start:.2f} - {turn.end:.2f}: Speaker {speaker}\n")

print("Speaker diarization completed.")

```

---

<div class="post-metadata">

**Author:** ![Navanit-AI](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/navanit-ai/32/30195_2.png) [@Navanit-AI](https://discuss.huggingface.co/u/Navanit-AI)\
**Post date:** [January 9, 2025, 8:50am UTC](https://discuss.huggingface.co/t/pyannotate-pipeline-not-working/134508/6 "2025-01-09T08:50:56Z")

</div>

The pyannote doesn’t ever starts with 0 is there any reason ?

---

<div class="post-metadata">

**Author:** ![Alanturner2](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/alanturner2/32/37542_2.png) [@Alanturner2](https://discuss.huggingface.co/u/Alanturner2)\
**Post date:** [January 9, 2025, 8:58am UTC](https://discuss.huggingface.co/t/pyannotate-pipeline-not-working/134508/7 "2025-01-09T08:58:29Z")

</div>

**It looks like your `pipeline()` call is hanging. Here are a few things to check:**

1. **Check Token** : Make sure your Hugging Face token is valid and has the right permissions.
2. **Audio File** : Double-check that the audio file path (`download1.wav`) is correct and accessible. Try with a smaller file to see if that helps.
3. **Colab Resources** : Colab has limited resources. You can check the GPU memory usage with:

```bash
!nvidia-smi

```

If it’s too high, Colab might disconnect.
4. **Debugging** : Add print statements to check where the code is stopping:

```python
print("Loading model...")
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization", use_auth_token="hf_xxxxxxxxxxxxxxxxxxx")
print("Model loaded, applying pipeline...")
diarization = pipeline(wav_file)
print("Diarization completed.")

```

5. **Run Locally** : If it still doesn’t work, try running the code locally or on a different platform (AWS, GCP).

If these steps don’t help, you might want to try a different diarization library like `SpeechBrain` or `pyAudioAnalysis`.

Good luck!
