The Kernel Audio Distance Toolkit (KADTK) provides an efficient and standardized implementation of Kernel Audio Distance (KAD)—a distribution-free, unbiased, and computationally efficient metric for evaluating generative audio.
To use the KAD toolkit, you must first install it. This library is created and tested on Python 3.10 on Linux but should work on Python >3.9.
To install the required libraries, run:
poetry installIf you gets CUDA related error, ensure your device is GPU-compatible and install the necessary software for CUDA support. Only pytorch~=2.1.x officially supported.
- if scipy causes some error, reinstall scipy: pip uninstall scipy && pip install scipy==1.11.2
- if charset causes some error, (re)install chardet: pip install chardet
- if CUDA causes some error, ensure your device is GPU-compatible and install the necessary software for CUDA support. Only pytorch~=2.1.x officially supported.
The toolkit provides a CLI command for computing KAD scores. It automatically extracts target embeddings and computes the KAD score between your generated audio files and an evaluation dataset.
kadtk {model_name} {target-set dir} {evaluation-set dir}(Enable Options)
--fad compute Fréchet Audio Distance instead of Kernel Audio Distance.
--inf option uses metric-inf extrapolation, and --indiv calculates metric for individual audios.
--force-emb-encode forces re-extraction of embeddings, not using cache.
--force_stats-calc forces re-calculation of kernel statistics, not using cache.
(Examples)
kadtk panns-wavegram-logmel /test_samples/generated_samples /test_samples/dcase2023_eval
kadtk vggish /test_samples/generated_samples /test_samples/dcase2023_eval --fad # it will calculate FAD instead of KAD
kadtk passt-fsd50k /test_samples/generated_samples /test_samples/dcase2023_eval --indiv scores.csv # it will save indivisual sample-wise scores in scores.csv
kadtk-embeds -m vggish panns-wavegram-logmel -d /test_samples/generated_samples /test_samples/dcase2023_eval # will only save each embeddings
| Model | Name in KADtk | Description | Creator |
|---|---|---|---|
| CLAP | clap-2023 |
general audio representation | Microsoft |
| CLAP | clap-laion-{audio/music} |
general audio, music representation | LAION |
| MERT | MERT-v1-95M-{layer} |
music understanding | m-a-p |
| VGGish | vggish |
general audio embedding | |
| PANNs | panns-cnn14-{16k/32k}, panns-wavegram-logmel |
general audio embedding | Kong, Qiuqiang, et al. |
| OpenL3 | openl3-{mel256/mel128}-{env/music} |
general audio embedding | Cramer, Aurora et al. |
| PaSST | passt-{base-{10s/20s/30s}, passt-openmic, passt-fsd50k (10s default, base for AudioSet) |
general audio embedding | Koutini, Khaled et al. |
| Encodec | encodec-emb |
audio codec | Facebook/Meta Research |
| DAC | dac-44kHz |
audio codec | Descript |
| CDPAM | cdpam-{acoustic/content} |
perceptual audio metric | Pranay Manocha et al. |
| Wav2vec 2.0 | w2v2-{base/large} |
speech representation | Facebook/Meta Research |
| HuBERT | hubert-{base/large} |
speech representation | Facebook/Meta Research |
| WavLM | wavlm-{base/base-plus/large} |
speech representation | Microsoft |
| Whisper | whisper-{tiny/base/small/medium/large} |
speech recognition | OpenAI |
Optionally, you can install dependencies that add additional embedding support. They are:
- PANNS(updated):
pip install git+https://github.com/DCASE2024-Task7-Sound-Scene-Synthesis/fadtk.git - CDPAM:
pip install cdpam - DAC:
pip install descript-audio-codec==1.0.0
@article{fad_embeddings,
author = {Tailleur, Modan and Lee, Junwon and Lagrange, Mathieu and Choi, Keunwoo and Heller, Laurie M. and Imoto, Keisuke and Okamoto, Yuki},
title = {Correlation of Fréchet Audio Distance With Human Perception of Environmental Audio Is Embedding Dependant},
journal = {arXiv:2403.17508},
url = {https://arxiv.org/abs/2403.17508},
year = {2024}
}@inproceedings{fadtk,
title = {Adapting Frechet Audio Distance for Generative Music Evaluation},
author = {Azalea Gui, Hannes Gamper, Sebastian Braun, Dimitra Emmanouilidou},
booktitle = {Proc. IEEE ICASSP 2024},
year = {2024},
url = {https://arxiv.org/abs/2311.01616},
}