Spaces:
Runtime error
Training Offline
Would I need to download the ASRDiarization pipeline and the pre-trained model in order to continue training my whisper model of choice offline?
Hey @Alextomana ! If you want to run the pipeline offline, you just need to make sure that you've downloaded your Whisper model .from_pretrained once before (this will save the model weights to your cache under ~/.cache/huggingface/models). If you call the ASRDiarization pipeline again, the model weights will be loaded from cache. The same is true of the speaker diarization weights
Thanks for the assistance @sanchit-gandhi ! I've been trying many different work-arounds, but I keep running into this error when trying to run offline as explained here https://github.com/pyannote/pyannote-audio/blob/develop/tutorials/applying_a_pipeline.ipynb.
Traceback (most recent call last):
File "run2.py", line 10, in <module>
pipeline = ASRDiarizationPipeline.from_pretrained()
File "/home/user/.local/lib/python3.8/site-packages/speechbox/diarize.py", line 41, in from_pretrained
diarization_pipeline = Pipeline.from_pretrained(diarizer_model, use_auth_token=use_auth_token)
File "/usr/local/lib/python3.8/dist-packages/pyannote/audio/core/pipeline.py", line 126, in from_pretrained
pipeline = Klass(**params)
File "/usr/local/lib/python3.8/dist-packages/pyannote/audio/pipelines/speaker_diarization.py", line 163, in __init__
self._embedding = PretrainedSpeakerEmbedding(
File "/usr/local/lib/python3.8/dist-packages/pyannote/audio/pipelines/speaker_verification.py", line 471, in PretrainedSpeakerEmbedding
return PyannoteAudioPretrainedSpeakerEmbedding(
File "/usr/local/lib/python3.8/dist-packages/pyannote/audio/pipelines/speaker_verification.py", line 391, in __init__
self.model_: Model = get_model(self.embedding, use_auth_token=use_auth_token)
File "/usr/local/lib/python3.8/dist-packages/pyannote/audio/pipelines/utils/getter.py", line 75, in get_model
model = Model.from_pretrained(
File "/usr/local/lib/python3.8/dist-packages/pyannote/audio/core/model.py", line 853, in from_pretrained
module_name: str = loaded_checkpoint["pyannote.audio"]["architecture"]["module"]
KeyError: 'pyannote.audio'
Here is my modification to the ASRDiarizationPipeline
from typing import List, Optional, Union
import numpy as np
import requests
import torch
from pyannote.audio import Pipeline
from torchaudio import functional as F
from transformers import pipeline
from transformers.pipelines.audio_utils import ffmpeg_read
class ASRDiarizationPipeline:
def __init__(
self,
asr_pipeline,
diarization_pipeline,
):
self.asr_pipeline = asr_pipeline
self.sampling_rate = asr_pipeline.feature_extractor.sampling_rate
self.diarization_pipeline = diarization_pipeline
@classmethod
def from_pretrained(
cls,
asr_model: Optional[str] = "openai/whisper-medium",
*,
diarizer_model: Optional[str] = "/home/user/config.yaml",
# diarizer_model: Optional[str] = "pyannote/speaker-diarization",
chunk_length_s: Optional[int] = 30,
use_auth_token: Optional[Union[str, bool]] = False,
# use_auth_token: Optional[Union[str, bool]] = True,
**kwargs,
):
asr_pipeline = pipeline(
"automatic-speech-recognition",
model=asr_model,
chunk_length_s=chunk_length_s,
use_auth_token=use_auth_token,
**kwargs,
)
diarization_pipeline = Pipeline.from_pretrained(diarizer_model, use_auth_token=use_auth_token)
return cls(asr_pipeline, diarization_pipeline)
This is my modified config.yaml file
pipeline:
name: pyannote.audio.pipelines.SpeakerDiarization
params:
clustering: AgglomerativeClustering
embedding: openai/whisper-medium
embedding_batch_size: 32
embedding_exclude_overlap: true
segmentation: pytorch_model.bin #<--- downloaded from pyannote/segmentation
segmentation_batch_size: 32
params:
clustering:
method: centroid
min_cluster_size: 15
threshold: 0.7153814381597874
segmentation:
min_duration_off: 0.5817029604921046
threshold: 0.4442333667381752
Any suggestions?
Hey @Alextomana ! It looks like pyannote isn't happy with what we're passing to .from_pretrained. Let's focus on making the pyannote pipeline work first. This code snippet should run if everything is working:
from pyannote.audio import Pipeline
diarizer_model = "/home/user/config.yaml"
pyannote_pipeline = Pipeline.from_pretrained(diarizer_model, use_auth_token=True)
Could you try setting the model path to absolute in config.yaml:
segmentation: /home/user/pytorch_model.bin
Solved the issue @sanchit-gandhi ! I had swapped speechbrain/spkrec-ecapa-voxceleb for openai/whisper-medium when I was messing around with some testing and never changed it back.
pipeline:
name: pyannote.audio.pipelines.SpeakerDiarization
params:
clustering: AgglomerativeClustering
embedding: speechbrain/spkrec-ecapa-voxceleb
embedding_batch_size: 32
embedding_exclude_overlap: true
segmentation: pytorch_model.bin
segmentation_batch_size: 32