[Python] PyAnnote Speaker Verification: All Speakers Getting Perfect 1.000 Similarity Scores

Discussão em 'Python' iniciado por Stack, Fevereiro 10, 2025.

  1. Stack

    Stack Membro Participativo

    I'm experiencing an issue with PyAnnote's speaker verification where all speakers are getting perfect similarity scores (1.000), even when they are clearly different voices.

    Environment


    • pyannote.audio: 3.1.1


    • torch: 2.5.1+cu124


    • Platform: Google Colab (Ubuntu Linux)


    • CUDA: Yes


    • GPU: Tesla T4


    • Python: 3.11


    • torchaudio: 2.5.1+cu124

    Issue

    Using pyannote/embedding for speaker verification, all speakers are getting perfect similarity scores (1.000) when compared to a reference sample, even between obviously different speakers in a professional audiobook.

    Code

    python

    import torch

    import torchaudio

    from pyannote.audio import Model

    import torch.nn.functional as F

    Setup

    device = torch.device("cuda")

    embedding_model = Model.from_pretrained("pyannote/embedding",

    use_auth_token='xxx').to(device)

    Load and process reference audio

    reference_path = "reference.flac" # 10-minute reference file

    reference_waveform, sample_rate = torchaudio.load(reference_path)

    reference_waveform = reference_waveform.mean(dim=0, keepdim=True).to(device)

    reference_features = embedding_model(reference_waveform.unsqueeze(0))

    reference_features = F.normalize(reference_features, p=2, dim=1)

    Load test audio segment

    test_path = "test.flac" # Different speaker segment

    test_waveform, = torchaudio.load(test_path)

    test_waveform = test_waveform.mean(dim=0, keepdim=True).to(device)

    test_embedding = embedding_model(test_waveform.unsqueeze(0))

    test_embedding = F.normalize(test_embedding, p=2, dim=1)

    Calculate similarity

    similarity = F.cosine_similarity(reference_features, test_embedding, dim=1).mean()

    print(f"Similarity score: {similarity.item():.6f}")

    Current Behavior


    • Every speaker gets similarity scores of 0.999+ to 1.000


    • This happens consistently across different speakers


    • Reference and speaker embeddings both have shape [1, 512]


    • Even clearly different voices (male/female) get perfect matches

    Debug Information

    Example similarity scores between different speakers:

    Speaker A vs Reference: 1.000000

    Speaker B vs Reference: 0.999998

    Speaker C vs Reference: 1.000000

    Tensor Shapes:

    Reference waveform shape: [1, 31246073]

    Reference embedding shape: [1, 512]

    Test embedding shape: [1, 512]

    What I've Tried


    • Testing with different audio segments


    • Testing with obviously different speakers


    • Using high-quality audio sources

    Question

    Why are all speakers getting perfect similarity scores (1.000) regardless of how different their voices are? Is this a known issue with the current version of PyAnnote?

    Continue reading...

Compartilhe esta Página