Wav2vec_unsupervised is a collection of scripts that automate running the Fairseq wav2vec 2.0 Unsupervised Speech Recognition pipeline as described in the official Fairseq project:
https://github.com/facebookresearch/fairseq/blob/main/examples/wav2vec/unsupervised/README.md
These scripts have been tested to work reliably in a Python virtual environment with PyTorch == 2.3.0
Before running the project, ensure the following requirements are met:
- Linux-based system (recommended)
- NVIDIA GPU with CUDA support
- Python virtual environment (venv)
- Git Installed
if Git is not already installed, run:
sudo apt-get install git
You must install a CUDA version that is compatible with your GPU and PyTorch version. Use the official NVIDIA CUDA Toolkit Archive to identify the correct version for your system: Note: In this project, we use CUDA version 12.3.0. LINK: https://developer.nvidia.com/cuda-12-3-0-download-archive
To determine the correct CUDA installer for your Linux system, run the following command in your terminal:
hostnamectl
You should see an output similar to the example below:
Static hostname: sup2
Icon name: computer-vm
Chassis: vm 🖴
Machine ID: da429e9cb1674e7a8911ea9304f2eb09
Boot ID: 997fe699749643148736a6a88de11bf6
Virtualization: google
Operating System: Debian GNU/Linux 12 (bookworm)
Kernel: Linux 6.1.0-42-cloud-amd64
Architecture: x86-64
Hardware Vendor: Google
Hardware Model: Google Compute Engine
Firmware Version: Google
Based on this information (operating system, architecture, and Linux distribution), select the appropriate CUDA 12.3.0 installer from the NVIDIA website.
deb (local) as shown in the image above.
Once you have identified the correct CUDA version and installer:
- Copy and paste the code in the
cuda_installation.txtfile in theunsupervised_wavfolder you cloned from GitHub.
All commands below should be executed from a terminal.
chmod +x setup_functions.sh \
wav2vec_functions.sh \
eval_functions.sh \
gans_functions.sh\
run_setup.sh \
run_wav2vec.sh \
run_eval.sh \
run_gans.sh \
utils.sh
This step installs dependencies, configures Fairseq, and prepares the environment.
./run_setup.sh
Inputs:
/path/to/train_audio_dataset – directory of training .wav audio files
/path/to/val_audio_dataset – directory of validation .wav audio files
/path/to/unlabelled/text_dataset – text file containing unlabeled sentences (one per line)
Audio and text inputs are independent and do not require alignment.
- All audio files must be in .wav format
- Audio files should have consistent sampling rates (recommended: 16 kHz)
./run_wav2vec.sh "/path/to/train_audio_dataset" \
"/path/to/val_audio_dataset" \
"/path/to/test_audio_dataset" \
"/path/to/unlabelled/text_dataset"
Before running run_gans.sh, you may want to adjust the training hyperparameters.
Edit the configuration file: unsupervised_wav/fairseq/examples/wav2vec/unsupervised/config/gan/w2vu.yaml
You can modify parameters such as:
- Batch size
- Learning rate
- Number of updates
This step is especially useful when working with low-resource datasets.
./run_gans.sh
During gans training, models are stored in a folder called multirun
the trained checkpoints from train_gans will be stored in a folder called multirun. The checkpoint will be stored in this format
multirun --
|
day/month/year --
|
time --
|
checkpoint_best.pt
checkpoint_last.pt
Therefore it is advisable to manually provide the path to the exact checkpoint to use under the variable $CHECKPOINT_DIR in the run_wav2vec.sh script
After training completes, run:
./run_eval.sh "/path/to/best_gan/model.pt"
The phone transcription of your test audio will be stored in file called test.txt. The path to the file is below:
data --
|
transcription_phones --
|
test.txt
- Install the correct CUDA version for your GPU
- Make all scripts executable
- Run
run_setup.sh - Ensure all audio files are
.wav - Optionally adjust GAN training configs
- Run
run_wav2vec.sh - Run
run_gans.sh - Run
./run_eval.sh "/path/to/best_gan/model.pt"
