yeyupiaoling/VoiceprintRecognition-Pytorch

This project uses a variety of advanced voiceprint recognition models such as EcapaTdnn, ResNetSE, ERes2Net, CAM++, etc. It is not excluded that more models will be supported in the future. At the same time, this project also supports MelSpectrogram, Spectrogram data preprocessing methods

VoiceprintRecognition‑Pytorch

A speaker‑verification / voice‑print toolkit built on PyTorch. It lets you train, evaluate and deploy models that can recognise who is speaking from an audio clip.

What it does

  • Implements a collection of state‑of‑the‑art speaker‑verification backbones (Ecapa‑Tdnn, TDNN, Res2Net, ResNetSE, ERes2Net, CAM++).
  • Offers several pooling layers (ASP, SAP, TSP, TAP, TSTP) and a range of loss functions (AAMLoss/ArcFace, SphereFace2, AMLoss, ARMLoss, CELoss, etc.).
  • Supports multiple front‑ends: classic acoustic features (MelSpectrogram, Spectrogram, MFCC, Fbank) and pretrained speech models from Hugging‑Face (wav2vec2, wavLM, etc.).
  • Includes data‑augmentation utilities (speed, volume, noise, reverberation, SpecAugment).
  • Provides scripts for data preparation, feature extraction, model training, evaluation, and inference APIs.
  • Comes with ready‑to‑use web and WeChat mini‑program demos for voice‑print comparison, speaker identification and diarisation.

Key features

Feature Details
Backbones EcapaTdnn, TDNN, Res2Net, ResNetSE, ERes2Net, CAM++
Pooling AttentiveStatsPool, SelfAttentivePooling, TemporalStatisticsPooling, TemporalAveragePooling, TemporalStatsPool
Losses AAMLoss (ArcFace), SphereFace2, AMLoss, ARMLoss, CELoss, SubCenterLoss, TripletAngularMarginLoss
Front‑ends MelSpectrogram, Spectrogram, MFCC, Fbank, wav2vec2.0, wavLM
Augmentation Speed perturb, volume gain, additive noise, reverberation, SpecAugment
Datasets supported CN‑Celeb, VoxCeleb1/2 (and any user‑provided list)
Evaluation metrics EER, MinDCF
Demo Online web pages and WeChat mini‑apps for voice‑print compare / recognition / diarisation

Installation

# PyTorch GPU (CUDA 11.8) – adjust version if needed
conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=11.8 -c pytorch -c nvidia

# Install the helper library used by the project
python -m pip install mvector -U -i https://pypi.tuna.tsinghua.edu.cn/simple

# Clone and install the package (editable install recommended)
git clone https://github.com/yeyupiaoling/VoiceprintRecognition-Pytorch.git
cd VoiceprintRecognition-Pytorch
pip install .

Quick start (typical workflow)

  1. Prepare data – download a speaker dataset (e.g., CN‑Celeb or VoxCeleb), place it under dataset/, and run:
    python create_data.py   # creates train/enroll/trials list files
    
  2. (Optional) Extract features – speeds up training:
    python extract_features.py --configs=configs/cam++.yml --save_dir=dataset/features
    
    Update the list paths in the config to the *_features.txt files.
  3. Train a model – pick a config (e.g., configs/ecapa_tdnn.yml) and run:
    CUDA_VISIBLE_DEVICES=0 python train.py          # single‑GPU
    # or multi‑GPU
    CUDA_VISIBLE_DEVICES=0,1 torchrun --standalone --nnodes=1 --nproc_per_node=2 train.py
    
    Logs are written to log/ and can be visualised with VisualDL:
    visualdl --logdir=log --host 0.0.0.0
    
  4. Evaluate – the same train.py script runs evaluation if do_eval: True in the config, reporting EER and MinDCF.
  5. Inference – after training, use the provided inference API (see inference.py in the repo) to embed a new utterance and compare it against enrolled speakers.

Demos & online services

License

The repository is released under the MIT License (see the LICENSE badge in the README).

Related

  • Project
  • Project
  • Project
  • Project