Skip to main content

VerifyVoice: Python Package

The VerifyVoice library is designed for text-independent speaker verification using voice embeddings. It provides an easy-to-use interface for speaker verification by loading a pre-trained model and extracting embeddings from audio files. You can compare audio files to determine if they belong to the same speaker by computing similarity scores between these embeddings. This documentation provides a basic overview and example usage to help you get started with the library.

Installation

To install the VerifyVoice package, use the following command:

pip install verifyvoice

Loading the Models

To use the VerifyVoice library, you need to load a pre-trained model using the ModelLoader class. Here is an example of how to initialize the model loader with a specific model:

from verifyvoice import ModelLoader 
model_loader = ModelLoader(model_name="WavLM", attention_heads=8)

You can select different pre-trained models trained with different attention heads (4, 8, 16). If your local machine does not have the models, they will automatically download from Hugging Face and save to the cache folder.

Extracting Embeddings

Once the model is loaded, you can extract embeddings from audio files. These embeddings represent the audio features used for comparison:

audio_path = '/path/to/audio.wav'
embedding = model_loader.get_embedding(audio_path)

Preprocessing Audio Data

The DataLoader class is responsible for loading and preprocessing audio data, including noise reduction and voice activity detection (VAD).

from verifyvoice import DataLoader

processed_audio = DataLoader.load_audio(audio_path, max_frames=160, evalmode=True, num_eval=10, vad_mode=True)

Threshold

The optimal threshold value for the currently loaded model is based on the number of attention heads used in the model configuration. Threshold values are critical in speaker verification tasks as they determine the decision boundary for classifying whether two audio samples belong to the same speaker or not.

threshold = model_loader.get_threshold()

Comparing Embeddings

To verify if two audio files belong to the same speaker, you can compute the cosine similarity between their embeddings. A higher cosine similarity score indicates higher similarity between the embeddings:

from sklearn.metrics.pairwise import cosine_similarity

# Compute cosine similarity between embeddings
similarity_1_4 = cosine_similarity(embedding1, embedding4).mean()
similarity_2_4 = cosine_similarity(embedding2, embedding4).mean()
similarity_4_1 = cosine_similarity(embedding4, embedding1).mean()

if similarity_1_4 >= threshold:
    print("same speaker")
else: 
    print("different speaker")

By following these steps, you can effectively use the VerifyVoice library for speaker verification tasks.

Metadata

Release files for verifyvoice 0.1.34

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for verifyvoice 0.1.34
File Size Uploaded Provenance Actions
verifyvoice-0.1.34.tar.gz 25.0 kB Without provenance Details for verifyvoice-0.1.34.tar.gz

Release files / verifyvoice-0.1.34.tar.gz

Download URL verifyvoice-0.1.34.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d0439aa4b28efb6e2615ffa0a754385ce3104c46c17e8451e2c61cce05ea95c5
BLAKE2b-256 checksum
How to use checksums
4bf05bb3c8e58e93600850bc7385c79118daba90a69f527adbe24bba1b9011ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Security for verifyvoice 0.1.34

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page