This repository contains the updated implementation of wav2tok, reformulated using the BEST-STD backbone with the proposed CTC-based pairwise alignment-based objective.
This project uses uv for fast and reproducible Python environment management.
- Install uv
macOS/Linux
curl -Ls https://astral.sh/uv/install.sh | shUsing pip
pip install uvgit clone https://github.com/madhavlab/wav2tok.git
cd wav2tokuv syncTraining is performed in two stages.
Train the model using only the contrastive objective.
- Open
configs/main.yaml. - Set:
use_ctcloss: falseRun training:
cd src/
uv run main.py --ckpt_dir /path/to/savedirEnable the CTC-based pairwise alignment loss and train with both objectives.
- In
configs/main.yaml, set:
use_ctcloss: true- Run training (optionally resuming from the Stage 1 checkpoint):
uv run main.py --ckpt_dir /path/to/savedirIn this stage, the model is optimized jointly with the contrastive loss and the CTC-based alignment loss.
To create the database, build the index, and perform retrieval:
uv run std_demo.pyFor a demonstration of word tokenization, check the following Jupyter Notebook:
demo/word_tokenization.ipynb- Dataset: LibriSpeech Word Alignments
If you find our work useful, please cite:
@inproceedings{banerjee2023wav2tok,
title={wav2tok: Deep Sequence Tokenizer for Audio Retrieval},
author={Banerjee, Adhiraj and Arora, Vipul},
booktitle={The Eleventh International Conference on Learning Representations},
year={2023}
}
The code in this project is adapted or modifed from the following projects:
- BEST-STD [MIT License]
- CTC python