importtorchfrompyannote.audio.pipelines.speaker_verificationimportPretrainedSpeakerEmbeddingmodel=PretrainedSpeakerEmbedding("speechbrain/spkrec-ecapa-voxceleb",device=torch.device("cuda"))frompyannote.audioimportAudiofrompyannote.coreimportSegmentaudio=Audio(sample_rate=16000)# extract embedding for a speaker speaking between t=3s and t=6sspeaker1=Segment(3.,6.)waveform1,sample_rate=audio.crop("audio.wav",speaker1)embedding1=model(waveform1[None])# extract embedding for a speaker speaking between t=7s and t=12sspeaker2=Segment(7.,12.)waveform2,sample_rate=audio.crop("audio.wav",speaker2)embedding2=model(waveform2[None])# compare embeddings using "cosine" distancefromscipy.spatial.distanceimportcdistdistance=cdist(embedding1,embedding2,metric="cosine")