ADescribe · audio.embed
Map recordings by sound (audio embeddings)
Which recordings sound alike, and how do they spread out?
Turns each recording into a 768-value embedding with the Audio Spectrogram Transformer (MIT's AudioSet model, written out in Python and R on torch from its safetensors weights; a one-time download you approve), then draws the recordings on a two-axis map (principal components) and lists each one's closest neighbors by cosine similarity. With a label column it reports how often the closest recording has the same label. The embeddings are saved with the result; to add them as columns for clustering, anomaly detection or a learner, use Add features from a pretrained model with the AST encoder.
A real result
Example “Sounds map”, recorded in both engines. In the app, “Try this example” loads it into Analyze.
4 recordings were turned into 768-value sound embeddings; the first two principal components keep 79% of their variance, and each file's closest neighbor has mean cosine similarity 0.53. The closest file has the same kind 0% of the time.
- Embedding size
- 768
- Mean similarity to the closest file
- 0.5318
- Closest file has the same label
- 0.0%
Plots
View data
| kind | PC 1 | PC 2 |
|---|---|---|
| tone_440 | −11.925 | −7.507 |
| chirp | −14.750 | −5.285 |
| noise | 23.109 | −10.904 |
| voice | 3.566 | 23.697 |
Assumptions
- Frozen model — The encoder isn't trained on your recordings; the embedding reflects what the model learned from AudioSet's YouTube clips.
- Two axes hide distance — The map keeps 79% of the embeddings' variance; nearest neighbors use every dimension.
Recordings on the map
| path | Seconds | PC 1 | PC 2 | Closest 3 (cosine) | kind |
|---|---|---|---|---|---|
| media/aud3/tone_440.wav | 1 | −11.925 | −7.507 | chirp.wav 0.64; ana_1.wav 0.43; noise.wav 0.40 | tone_440 |
| media/aud3/chirp.wav | 1 | −14.750 | −5.285 | tone_440.wav 0.64; ana_1.wav 0.44; noise.wav 0.35 | chirp |
| media/aud3/noise.wav | 1 | 23.109 | −10.904 | tone_440.wav 0.40; ana_1.wav 0.38; chirp.wav 0.35 | noise |
| media/aud3/ana_1.wav | 1.500 | 3.566 | 23.697 | chirp.wav 0.44; tone_440.wav 0.43; noise.wav 0.38 | voice |
- Audio Spectrogram Transformer (Gong, Chung & Glass 2021), MIT, fine-tuned on AudioSet: the mean of the class and distillation token outputs, averaged over 10.24-s windows; float64. Map: principal components of the centered embeddings, each axis signed so its largest coordinate is positive. Save the embeddings as columns with Add features from a pretrained model.
4 recordings were turned into 768-value sound embeddings; the first two principal components keep 79% of their variance, and each file's closest neighbor has mean cosine similarity 0.53. The closest file has the same kind 0% of the time.
- Embedding size
- 768
- Mean similarity to the closest file
- 0.5318
- Closest file has the same label
- 0.0%
To keep this page light, the plots are shown once, under the R tab.
Assumptions
- Frozen model — The encoder isn't trained on your recordings; the embedding reflects what the model learned from AudioSet's YouTube clips.
- Two axes hide distance — The map keeps 79% of the embeddings' variance; nearest neighbors use every dimension.
Recordings on the map
| path | Seconds | PC 1 | PC 2 | Closest 3 (cosine) | kind |
|---|---|---|---|---|---|
| media/aud3/tone_440.wav | 1 | −11.925 | −7.507 | chirp.wav 0.64; ana_1.wav 0.43; noise.wav 0.40 | tone_440 |
| media/aud3/chirp.wav | 1 | −14.750 | −5.285 | tone_440.wav 0.64; ana_1.wav 0.44; noise.wav 0.35 | chirp |
| media/aud3/noise.wav | 1 | 23.109 | −10.904 | tone_440.wav 0.40; ana_1.wav 0.38; chirp.wav 0.35 | noise |
| media/aud3/ana_1.wav | 1.500 | 3.566 | 23.697 | chirp.wav 0.44; tone_440.wav 0.43; noise.wav 0.38 | voice |
- Audio Spectrogram Transformer (Gong, Chung & Glass 2021), MIT, fine-tuned on AudioSet: the mean of the class and distillation token outputs, averaged over 10.24-s windows; float64. Map: principal components of the centered embeddings, each axis signed so its largest coordinate is positive. Save the embeddings as columns with Add features from a pretrained model.
Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.
Worked examples in the app
- Sounds mapaud3_sounds · audio: path · label: kind
- Voices map k1aud3_voices · audio: path · label: speaker
- Degenerate all naaud3_sounds · audio: path · label: kind
- Degenerate empty after filteraud3_sounds · audio: path · label: kind
- Degenerate n1aud3_sounds · audio: path · label: kind
- Degenerate n2aud3_sounds · audio: path · label: kind
- Degenerate n3aud3_sounds · audio: path · label: kind
- Pdna missing path and labelpdna_audio · audio: path · label: speaker
In the guides
Where it sits in the decision guides
- Representation visualization (t-SNE, UMAP) · DS & ML Decision Guide · Describe — summarize and visualize
- Multimodal data exploration (text, image, video) · DS & ML Decision Guide · Describe — summarize and visualize
What you need
- Audio file pathcategorical · 1 column
- A column of audio file paths, such as the path column of an audio folder (Data → Add audio folder…). WAV, FLAC, MP3, M4A and OGG are read.
- Label (optional)categorical · 0–1 column
- A known class for each recording (a folder name, a category): colors the map and checks whether neighbors share it.
Choices you make
options
- Neighbors listeddefault 3
How many of the most similar other recordings to list for each file.
Advanced
- Seconds read per filedefault 60
Only the first part of each file is used; each 10 seconds take about 2–4 s on one CPU thread.
Checks and remedies
CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.
Frozen modelNot checked from data: state why it holds
The encoder isn't trained on your recordings; the embedding reflects what it learned from AudioSet's YouTube clips.
Two axes hide distanceNot checked from data: state why it holds
The map shows only the two directions with the most variance; nearest neighbors use every dimension.
What it reports
- n_rows
- Files with a path that decode are analyzed; the rest are counted. Only the first part of each file is read.
- n_files
- Files with a path that decode are analyzed; the rest are counted. Only the first part of each file is read.
- n_embedded
- Files with a path that decode are analyzed; the rest are counted. Only the first part of each file is read.
- n_unreadable
- Files with a path that decode are analyzed; the rest are counted. Only the first part of each file is read.
- n_no_path
- Files with a path that decode are analyzed; the rest are counted. Only the first part of each file is read.
- audio_seconds
- Files with a path that decode are analyzed; the rest are counted. Only the first part of each file is read.
- dim
- Each recording's 768-value AST embedding, drawn on its first two principal components, with its closest neighbors.
- pc1_share
- Each recording's 768-value AST embedding, drawn on its first two principal components, with its closest neighbors.
- pc2_share
- Each recording's 768-value AST embedding, drawn on its first two principal components, with its closest neighbors.
- k_neighbors
- Each recording's 768-value AST embedding, drawn on its first two principal components, with its closest neighbors.
- mean_nn_similarity
- Each recording's 768-value AST embedding, drawn on its first two principal components, with its closest neighbors.
- nn_label_accuracy
- How often a file's most similar other file has the same known speaker or label.
Python and R
Python and R agree to 6 decimals (relative tolerance 1e-6). Python uses pandas, numpy, torch, safetensors, codesplash; R uses torch, jsonlite, nanoparquet, codesplashr.
Default traps between the two languages
- Both engines read the same decoded samples and run the same AST twin in float64 on one thread; embeddings agree to about 1e-14. The map's axes come from LAPACK's SVD in both engines with each axis signed by its largest coordinate, so they agree to rounding.
The exact script CodeSplash ran for example “Sounds map” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Map recordings by sound (audio embeddings)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method audio.embed 1.0.0 · spec 40645584d502d032
# Dataset: aud3_sounds (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import os
import numpy as np
import pandas as pd
import torch
import codesplash as cs
from codesplash import ml as csml
from codesplash.audio import ast # Audio Spectrogram Transformer (twin: codesplashr cs_ast_*)
# %% Audio files listed in the path column
PATH = "path"
LABEL = "kind"
K = int(3)
DATA_DIR = os.path.dirname(os.path.abspath("tests/parity/fixtures/aud3_sounds.parquet"))
df = pd.read_parquet("tests/parity/fixtures/aud3_sounds.parquet", columns=[PATH] if LABEL is None else [PATH, LABEL])
if not len(df):
cs.cs_error("CS_E_NO_ROWS")
paths = [None if (pd.isna(p) or not str(p).strip()) else str(p) for p in df[PATH].tolist()] # None, NaN, pd.NA: no path
if all(p is None for p in paths):
cs.cs_error("CS_E_ALL_MISSING", column=PATH)
# %% Media files (audio column path)
# In the app the files were decoded once into float32 arrays (media.json in the run folder). Elsewhere they are
# decoded here the same way: PNG and WAV give the app's values; JPEG, MP3 and other lossy files can differ slightly.
import json as _media_json
from codesplash import media as cs_media
media = cs_media.setup(_media_json.loads("{\"ids_column\":\"media_id\",\"kind\":\"audio\",\"path_column\":\"path\",\"role\":\"audio\",\"transform\":{\"max_seconds\":60,\"mono\":true,\"offset_seconds\":0,\"sample_rate\":16000}}"), "target/academy-parity/run-8142/audio.embed/sounds-map/out-python", df, "tests/parity/fixtures/aud3_sounds.parquet")
media_ids = cs_media.ids_of(media, df)
if media.get("root") is None:
media["root"] = DATA_DIR # outside the app, relative paths start next to the data file
warnings = []
status = cs_media.status(media, [m if p is not None else None for m, p in zip(media_ids, paths)])
ok = [i for i, (p, s) in enumerate(zip(paths, status)) if p is not None and s is None]
n_no_path = sum(p is None for p in paths)
unreadable = [i for i, (p, s) in enumerate(zip(paths, status)) if p is not None and s is not None]
if not ok:
i = unreadable[0]
cs.cs_error("CS_E_MEDIA_DECODE", file=paths[i], reason=status[i])
if len(ok) < 3:
cs.cs_error("CS_E_TOO_FEW_ROWS", what="A map of recordings", min=3, n=len(ok))
if n_no_path:
warnings.append(f"{n_no_path} rows have no file path and are left out.")
if unreadable:
warnings.append(f"{len(unreadable)} files couldn't be decoded and are left out (first: {paths[unreadable[0]]}: {status[unreadable[0]]}).")
# %% Clip embeddings (AST, float64 on one thread: the Parity profile)
torch.set_num_threads(1)
model = ast.load(ast.locate())
progress = cs.progress(f"Embedding {len(ok)} recordings", total=len(ok))
secs, E = [], np.zeros((len(ok), int(model["config"]["hidden_size"])))
for k, i in enumerate(ok):
clip = np.asarray(cs_media.audio(media, [media_ids[i]])[0], dtype=np.float64)
secs.append(clip.size / 16000.0)
E[k] = ast.run(model, [clip])["embeddings"][0]
progress.update(k + 1)
progress.done()
# %% Map (first two principal components) and nearest neighbors by cosine similarity
pca = ast.pca_map(E)
U = E / np.sqrt(np.sum(E * E, axis=1))[:, None]
S = U @ U.T
names = [os.path.basename(paths[i]) for i in ok]
k_eff = min(K, len(ok) - 1)
nbrs = ast.neighbors(S, k_eff)
lab = None
nn_acc = None
if LABEL is not None:
lab = [None if pd.isna(v) else str(v) for v in (df[LABEL].tolist()[i] for i in ok)] # None, NaN, pd.NA: unlabeled
hits, n_id = 0, 0
for a in range(len(ok)):
if lab[a] is None:
continue
cand = [(b, S[a, b]) for b in range(len(ok)) if b != a and lab[b] is not None]
if not cand:
continue
b = max(cand, key=lambda t: (t[1], -t[0]))[0]
hits += int(lab[b] == lab[a])
n_id += 1
nn_acc = hits / n_id if n_id else None
# %% Artifact: one row per file with its embedding
out = csml.out_dir("target/academy-parity/run-8142/audio.embed/sounds-map/out-python")
art = pd.DataFrame({"row": np.array(ok, dtype=np.int64), "media_id": [media_ids[i] for i in ok], "path": [paths[i] for i in ok],
"pc1": pca["coords"][:, 0], "pc2": pca["coords"][:, 1]})
for d in range(E.shape[1]):
art[f"emb_{d + 1}"] = E[:, d]
art.to_parquet(os.path.join(out, "embeddings.parquet"), index=False)
# %% Assumptions
assumptions = [
{"key": "frozen", "label": "Frozen model", "status": "info",
"detail": "The encoder isn't trained on your recordings; the embedding reflects what the model learned from AudioSet's YouTube clips."},
{"key": "map_distortion", "label": "Two axes hide distance", "status": "info",
"detail": f"The map keeps {100 * (pca['share'][0] + pca['share'][1]):.0f}% of the embeddings' variance; nearest neighbors use every dimension."},
]
# %% Result
values = {"n_rows": len(df), "n_files": len(ok) + len(unreadable), "n_embedded": len(ok), "n_unreadable": len(unreadable), "n_no_path": n_no_path,
"audio_seconds": float(sum(secs)), "dim": int(E.shape[1]), "pc1_share": float(pca["share"][0]), "pc2_share": float(pca["share"][1]),
"k_neighbors": k_eff, "mean_nn_similarity": float(np.mean([nb[0][1] for nb in nbrs])), "nn_label_accuracy": nn_acc}
rows = []
for k, i in enumerate(ok):
r = {"file": paths[i], "seconds": secs[k], "pc1": float(pca["coords"][k, 0]), "pc2": float(pca["coords"][k, 1]),
"neighbors": "; ".join(f"{names[b]} {s:.2f}" for b, s in nbrs[k])}
if lab is not None:
r["label"] = lab[k]
rows.append(r)
cols = [{"key": "file", "label": PATH, "type": "string"}, {"key": "seconds", "label": "Seconds", "type": "number"},
{"key": "pc1", "label": "PC 1", "type": "number"}, {"key": "pc2", "label": "PC 2", "type": "number"},
{"key": "neighbors", "label": f"Closest {k_eff} (cosine)", "type": "string"}]
if lab is not None:
cols.append({"key": "label", "label": LABEL, "type": "string"})
tables = [{"key": "files", "title": "Recordings on the map", "columns": cols, "rows": rows[:500], "note": "First 500 files." if len(rows) > 500 else None}]
roles_map = {"x": cs.col("PC 1", pca["coords"][:, 0].tolist()), "y": cs.col("PC 2", pca["coords"][:, 1].tolist())}
if lab is not None:
levels = sorted({v for v in lab if v is not None})
if len(levels) <= 8:
roles_map["color"] = cs.col(LABEL, [v if v is not None else None for v in lab], "categorical", levels=levels)
charts = [cs.chart("map", "scatter", "Recordings by sound (first two principal components of the embeddings)", roles_map, controls={"fit": "none"})]
summary = (f"{len(ok)} recordings were turned into {E.shape[1]}-value sound embeddings; the first two principal components keep "
f"{100 * (pca['share'][0] + pca['share'][1]):.0f}% of their variance, and each file's closest neighbor has mean cosine similarity "
f"{values['mean_nn_similarity']:.2f}.")
if nn_acc is not None:
summary += f" The closest file has the same {LABEL} {100 * nn_acc:.0f}% of the time."
cs.publish({
"method": "audio.embed",
"methodVersion": "1.0.0",
"title": "Sound embeddings",
"engine": cs.engine_info("numpy", "torch"),
"n": len(ok),
"summary": summary,
"statistics": [{"key": "dim", "label": "Embedding size", "value": int(E.shape[1]), "format": "integer"},
{"key": "mean_nn_similarity", "label": "Mean similarity to the closest file", "value": values["mean_nn_similarity"]}]
+ ([{"key": "nn_label_accuracy", "label": "Closest file has the same label", "value": nn_acc, "format": "percent"}] if nn_acc is not None else []),
"tables": tables,
"assumptions": assumptions,
"warnings": warnings,
"notes": ["Audio Spectrogram Transformer (Gong, Chung & Glass 2021), MIT, fine-tuned on AudioSet: the mean of the class and distillation "
"token outputs, averaged over 10.24-s windows; float64. Map: principal components of the centered embeddings, each axis signed "
"so its largest coordinate is positive. Save the embeddings as columns with Add features from a pretrained model."],
"charts": charts,
"artifacts": [{"key": "embeddings", "path": os.path.join(out, "embeddings.parquet"), "format": "parquet"}],
"values": values,
})
The exact script CodeSplash ran for example “Sounds map” · R version 4.5.1 (2025-06-13)
# Map recordings by sound (audio embeddings)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method audio.embed 1.0.0 · spec 40645584d502d032
# Dataset: aud3_sounds (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr) # cs_ast_* (Audio Spectrogram Transformer), cs_ast_pca_map, cs_ast_neighbors
# %% Audio files listed in the path column
PATH <- "path"
LABEL <- "kind"
K <- as.integer(3)
DATA_DIR <- dirname(normalizePath("tests/parity/fixtures/aud3_sounds.parquet"))
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/aud3_sounds.parquet", col_select = if (is.null(LABEL)) PATH else c(PATH, LABEL)))
if (nrow(df) == 0) cs_error("CS_E_NO_ROWS")
paths <- as.character(df[[PATH]])
paths[is.na(paths) | !nzchar(trimws(paths))] <- NA_character_
if (all(is.na(paths))) cs_error("CS_E_ALL_MISSING", column = PATH)
# %% Media files (audio column path)
# In the app the files were decoded once into float32 arrays (media.json in the run folder). Elsewhere they are
# decoded here the same way: PNG and WAV give the app's values; JPEG, MP3 and other lossy files can differ slightly.
media <- cs_media_setup(jsonlite::fromJSON("{\"ids_column\":\"media_id\",\"kind\":\"audio\",\"path_column\":\"path\",\"role\":\"audio\",\"transform\":{\"max_seconds\":60,\"mono\":true,\"offset_seconds\":0,\"sample_rate\":16000}}", simplifyVector = FALSE), "target/academy-parity/run-8142/audio.embed/sounds-map/out-r", df,
"tests/parity/fixtures/aud3_sounds.parquet")
media_ids <- cs_media_ids(media, df)
if (is.null(media$root)) media$root <- DATA_DIR # outside the app, relative paths start next to the data file
warnings <- character(0)
status <- cs_media_status(media, ifelse(is.na(paths), NA_character_, media_ids))
ok <- which(!is.na(paths) & is.na(status))
n_no_path <- sum(is.na(paths))
unreadable <- which(!is.na(paths) & !is.na(status))
if (!length(ok)) cs_error("CS_E_MEDIA_DECODE", file = paths[unreadable[1]], reason = status[unreadable[1]])
if (length(ok) < 3) cs_error("CS_E_TOO_FEW_ROWS", what = "A map of recordings", min = 3, n = length(ok))
if (n_no_path > 0) warnings <- c(warnings, sprintf("%d rows have no file path and are left out.", n_no_path))
if (length(unreadable)) warnings <- c(warnings, sprintf("%d files couldn't be decoded and are left out (first: %s: %s).",
length(unreadable), paths[unreadable[1]], status[unreadable[1]]))
# %% Clip embeddings (AST, float64 on one thread: the Parity profile)
torch::torch_set_num_threads(1L)
model <- cs_ast_load(cs_ast_locate())
progress <- cs_progress(sprintf("Embedding %d recordings", length(ok)), total = length(ok))
secs <- numeric(length(ok))
E <- matrix(0, nrow = length(ok), ncol = as.integer(model$config$hidden_size))
for (k in seq_along(ok)) {
clip <- as.numeric(cs_media_audio(media, media_ids[ok[k]])[[1]])
secs[k] <- length(clip) / 16000
E[k, ] <- cs_ast_run(model, list(clip))$embeddings[1, ]
cs_progress_update(progress, k)
}
cs_progress_done(progress)
# %% Map (first two principal components) and nearest neighbors by cosine similarity
pca <- cs_ast_pca_map(E)
U <- E / sqrt(rowSums(E * E))
S <- U %*% t(U)
names_ <- basename(paths[ok])
k_eff <- min(K, length(ok) - 1L)
nbrs <- cs_ast_neighbors(S, k_eff)
lab <- NULL
nn_acc <- NULL
if (!is.null(LABEL)) {
lab <- as.character(df[[LABEL]])[ok]
hits <- 0L
n_id <- 0L
for (a in seq_along(ok)) {
if (is.na(lab[a])) next
row <- vapply(seq_along(ok), function(b) if (b != a && !is.na(lab[b])) S[a, b] else -Inf, numeric(1))
if (!any(is.finite(row))) next
b <- which.max(row)
hits <- hits + as.integer(lab[b] == lab[a])
n_id <- n_id + 1L
}
nn_acc <- if (n_id > 0) hits / n_id else NULL
}
# %% Artifact: one row per file with its embedding
out <- cs_ml_out_dir("target/academy-parity/run-8142/audio.embed/sounds-map/out-r")
art <- data.frame(row = as.integer(ok - 1L), media_id = media_ids[ok], path = paths[ok], pc1 = pca$coords[, 1], pc2 = pca$coords[, 2],
stringsAsFactors = FALSE)
for (d in seq_len(ncol(E))) art[[sprintf("emb_%d", d)]] <- E[, d]
nanoparquet::write_parquet(art, file.path(out, "embeddings.parquet"))
# %% Assumptions
assumptions <- list(
list(key = "frozen", label = "Frozen model", status = "info",
detail = "The encoder isn't trained on your recordings; the embedding reflects what the model learned from AudioSet's YouTube clips."),
list(key = "map_distortion", label = "Two axes hide distance", status = "info",
detail = sprintf("The map keeps %.0f%% of the embeddings' variance; nearest neighbors use every dimension.", 100 * (pca$share[1] + pca$share[2])))
)
# %% Result
values <- list(n_rows = nrow(df), n_files = length(ok) + length(unreadable), n_embedded = length(ok), n_unreadable = length(unreadable),
n_no_path = n_no_path, audio_seconds = sum(secs), dim = ncol(E), pc1_share = pca$share[1], pc2_share = pca$share[2],
k_neighbors = k_eff, mean_nn_similarity = mean(vapply(nbrs, function(nb) nb$similarity[1], numeric(1))), nn_label_accuracy = nn_acc)
rows <- lapply(seq_along(ok), function(k) {
r <- list(file = paths[ok[k]], seconds = secs[k], pc1 = pca$coords[k, 1], pc2 = pca$coords[k, 2],
neighbors = paste(sprintf("%s %.2f", names_[nbrs[[k]]$index], nbrs[[k]]$similarity), collapse = "; "))
if (!is.null(lab)) r$label <- lab[k]
r
})
cols <- list(list(key = "file", label = PATH, type = "string"), list(key = "seconds", label = "Seconds", type = "number"),
list(key = "pc1", label = "PC 1", type = "number"), list(key = "pc2", label = "PC 2", type = "number"),
list(key = "neighbors", label = sprintf("Closest %d (cosine)", k_eff), type = "string"))
if (!is.null(lab)) cols[[length(cols) + 1L]] <- list(key = "label", label = LABEL, type = "string")
tables <- list(list(key = "files", title = "Recordings on the map", columns = cols, rows = head(rows, 500),
note = if (length(rows) > 500) "First 500 files." else NULL))
roles_map <- list(x = cs_col("PC 1", pca$coords[, 1]), y = cs_col("PC 2", pca$coords[, 2]))
if (!is.null(lab)) {
lv <- sort(unique(lab[!is.na(lab)]), method = "radix")
if (length(lv) <= 8) roles_map$color <- cs_col(LABEL, lab, "categorical", levels = lv)
}
charts <- list(cs_chart("map", "scatter", "Recordings by sound (first two principal components of the embeddings)", roles_map, controls = list(fit = "none")))
summary <- sprintf(paste0("%d recordings were turned into %d-value sound embeddings; the first two principal components keep %.0f%% of their variance, ",
"and each file's closest neighbor has mean cosine similarity %.2f."),
length(ok), ncol(E), 100 * (pca$share[1] + pca$share[2]), values$mean_nn_similarity)
if (!is.null(nn_acc)) summary <- paste(summary, sprintf("The closest file has the same %s %.0f%% of the time.", LABEL, 100 * nn_acc))
statistics <- list(list(key = "dim", label = "Embedding size", value = ncol(E), format = "integer"),
list(key = "mean_nn_similarity", label = "Mean similarity to the closest file", value = values$mean_nn_similarity))
if (!is.null(nn_acc)) statistics[[length(statistics) + 1L]] <- list(key = "nn_label_accuracy", label = "Closest file has the same label", value = nn_acc, format = "percent")
cs_publish(list(
method = "audio.embed",
methodVersion = "1.0.0",
title = "Sound embeddings",
engine = cs_engine_info("torch", "nanoparquet"),
n = length(ok),
summary = summary,
statistics = statistics,
tables = tables,
assumptions = assumptions,
warnings = as.list(warnings),
notes = list(paste0("Audio Spectrogram Transformer (Gong, Chung & Glass 2021), MIT, fine-tuned on AudioSet: the mean of the class and distillation ",
"token outputs, averaged over 10.24-s windows; float64. Map: principal components of the centered embeddings, each axis signed ",
"so its largest coordinate is positive. Save the embeddings as columns with Add features from a pretrained model.")),
charts = charts,
artifacts = list(list(key = "embeddings", path = file.path(out, "embeddings.parquet"), format = "parquet")),
values = values
))
Sources
- Gong, Y., Chung, Y.-A., & Glass, J. (2021). AST: Audio Spectrogram Transformer. Proceedings of Interspeech, 571–575.
- Gemmeke, J. F., Ellis, D. P. W., Freedman, D., et al. (2017). Audio Set: An ontology and human-labeled dataset for audio events. Proceedings of ICASSP, 776–780.
From the CodeSplash method registry · audio.embed v1.0.0.