This repository contains experiments for training accent classifiers using Whisper and Wav2Vec2 based models. It also provides utilities for preparing data from the Common Voice corpus and visualising the resulting embeddings.
Use my model via Huggingface: https://huggingface.co/Amirjab21/accent-classifier
model/– Whisper model implementation with additions for accent classification. Key files includeload_model.pyfor downloading and loading checkpoints andaccent_model.pywhich wraps Whisper with a linear classifier.training/– Dataset and training helpers.accent_dataset.pydefinesContrastiveDatasetwhich converts Common Voice entries into mel spectrograms and tokenised text.train_utils.pyprovides training loops and evaluation utilities.
finetune-wav2vec/– Scripts for fine‑tuning Wav2Vec2 models.
train.py– Main training script for the accent classifier.test.pyandtest-53-accents.py– Evaluation routines for small and large numbers of accent classes.add_new_accents.py/add_new_accents2.py– Extend an existing model to recognise additional accents by updating the classification head.
extract_commonvoice.py– Convert and filter Common Voice audio into a Parquet data set.format_dataset.py– Map the diverse accent labels from Common Voice to a smaller controlled vocabulary and group related accents by region.upload.py– Helper script to push processed datasets to the Hugging Face Hub.
visualise_accents.py,visualise_accents_new.pyandvisualise_accents new.py– Generate PCA and t‑SNE plots for the learned accent embeddings.
letter_wav2vec.pyandphoneme.py– Experiments with phoneme level processing and Wav2Vec2 models.requirements.txt– Python dependencies for the project.
Install the dependencies and ensure a GPU is available for best performance.
pip install -r requirements.txtTraining can then be started with:
python train.pyThe scripts in finetune-wav2vec/ follow a similar pattern for Wav2Vec2 based
experiments.
Processed dataframes can be pushed to the Hugging Face Hub using upload.py once
HF_TOKEN is configured in your environment.
Visualization scripts read trained checkpoints to produce tsne and PCA plots of
accent embeddings.