An unofficial ONNX conversion of laion/clap2-large-audioxl-s1B, LAION's CLAP2 contrastive audio-text model. It is not made or endorsed by LAION. All credit for the model goes to its authors; see the original model card for its training data, scores, intended use and limitations.
AudioNaFlexPatchify does. The graph takes the waveform.encode_audio(..., normalize=True) and encode_text(..., normalize=True).= 0.9999 between the original's and the ONNX embeddings, for a tone, noise, a 0.2 s clip and English text.
| File | |
|---|---|
onnx/audio_model.onnx |
waveform: float32 (1, samples), mono, 32000 Hz, 1024 samples to 30 s -> audio_embeds: (1, 960) |
onnx/text_model.onnx |
input_ids: int64 (1, 256) -> text_embeds: (1, 960) |
tokenizer.json |
from the original repo (GPT-2 style BPE; adds the start and end tokens). Pad to 256 with id 50258. |
bachmcp.json |
the same facts, for programs |
import json, numpy as np, onnxruntime as ort
from tokenizers import Tokenizer
audio = ort.InferenceSession("onnx/audio_model.onnx")
text = ort.InferenceSession("onnx/text_model.onnx")
tok = Tokenizer.from_file("tokenizer.json")
tok.enable_truncation(256); tok.enable_padding(length=256, pad_id=50258)
wave = np.zeros(32000 * 3, np.float32) # your sound: mono, 32000 Hz
a = audio.run(None, {"waveform": wave[None]})[0][0]
t = text.run(None, {"input_ids": np.array([tok.encode("A cello plays a slow melody.").ids])})[0][0]
print(float(a @ t)) # cosine similarity
Sounds longer than 30 s: cut them into pieces and average the embeddings (the original was trained on clips of at most 30 s). Write prompts as short full sentences, as the original card advises.
Converted with export_onnx.py for bach-mcp.
Apache-2.0, as the original (the full text is in LICENSE). Please cite the original authors:
@misc{wijngaard2026laionaudioxlwebscalecorpusscaling,
title={LAION-Audio-XL: A Web-Scale Corpus and Scaling Studies for Contrastive Language-Audio Pretraining},
author={Gijs Wijngaard and Felix Förster and Ross Wightman and Marianna Nezhurina and Christoph Schuhmann and Jenia Jitsev and A. Sophia Koepke},
year={2026},
eprint={2611.11592},
archivePrefix={arXiv},
primaryClass={cs.SD},
url={https://arxiv.org/abs/2611.11592},
}
onnx/text_model.onnx 696 MBonnx/audio_model.onnx 673 MB