Skip to content

Speaker embeddings and verification: x-vectors, ECAPA-TDNN, EER and DCF

A speaker embedding turns any length of speech into one vector per voice. See how x-vectors and ECAPA-TDNN are built and trained, and score same-or-different trials with the equal error rate and the detection cost.

Advanced ~17 min11 steps

What runs in CodeSplash

You will be able to

  • Describe statistics pooling and why speaker embeddings come from a speaker classifier
  • Describe ECAPA-TDNN's attentive pooling and angular-margin training
  • Compute a detection cost and tell the minimum cost from the actual cost at a threshold
  • Spot the shortcuts that inflate verification results, and treat embeddings as biometric data

Read first

01

One vector per voice

Read

Speaker recognition asks who is speaking, whatever they say. A speaker embeddingSpeaker embeddingA vector (192 values from ECAPA-TDNN) that is close for recordings of the same voice, whatever is said. Biometric data. answers with one fixed-length vector per recording, close for the same voice and far for different ones. Compare two recordings by the cosine of their embeddings; set a threshold for verification (same person or not); cluster embeddings to group voices.

The trick is in training: teach a network to classify thousands of speakers, then throw away the classifier and keep an inner layer. A layer that separates thousands of known voices separates new ones too.

02

x-vectors: pool the frames

Read

x-vectors run time-delay layers (dilated convolutions over frames) to get one vector per frame. Speech length varies, so statistics poolingStatistics poolingTurns any number of frame vectors into one fixed vector by stacking their mean and standard deviation; attentive pooling weights frames. turns any number of frame vectors into one: the mean and the standard deviation, stacked. In the reference's example three frame vectors pool to means of 0.667 and standard deviations of 0.471 per dimension. A few more layers follow, and the embedding is read from one of them.

Classic systems scored pairs with a trained PLDA back end; cosine scoring is the simpler choice.

Reference · AUD048 · Explained herex-vectorsA supervised speaker-embedding approach using a time-delay neural network and statistics pooling to map variable-duration speech into fixed-length vectors.
03

ECAPA-TDNN: attention and a margin

Read

ECAPA-TDNN refines the recipe. Its frame layers use multi-scale (Res2Net) blocks with channel attention, and it joins features from several depths. Its pooling is attentive: a learned weight per frame, so silence and noise count less.

Training uses an angular-margin softmaxAngular-margin softmaxA classification loss that scores the true class by s·cos(θ + m), forcing a gap between classes on the sphere of embeddings.: with unit-length embeddings and class vectors at angle θ\theta, the true class scores scos⁡(θy+m)s \cos(\theta_y + m). The margin mm makes the model win by a gap. With θ=0.5\theta = 0.5, m=0.2m = 0.2 and s=30s = 30, the reference's example gives 22.95.

Reference · AUD049 · Runs in CodeSplashECAPA-TDNNA speaker-embedding architecture combining Res2Net-style temporal blocks, channel attention, aggregation across layers, and attentive statistics pooling.
04

Voices in CodeSplash

Read
Speaker embeddingsRecorded · Python and R agreeRecorded 2026-11-25 · 18 values compared
R

6 recordings were turned into 192-value speaker embeddings and fell into 3 voice groups at cosine similarity 0.5. Among 3 same-speaker and 12 different-speaker pairs, the equal error rate was 0.0% and the closest other file had the same speaker 100% of the time.

Voice groups
3
Mean similarity to the closest file
0.6686
EER
0.0%

Plots

Voice similarity (cosine)What do the values of a square or rectangular result matrix look like at a glance?
View data
FileSimilarityFileCosine similarity
1. ana_1.wav1.001. ana_1.wav1
2. ana_2.wav0.761. ana_1.wav0.7616
3. ben_1.wav0.281. ana_1.wav0.2784
4. ben_2.wav0.321. ana_1.wav0.3230
5. cal_1.wav0.481. ana_1.wav0.4774
6. cal_2.wav0.411. ana_1.wav0.4109
1. ana_1.wav0.762. ana_2.wav0.7616
2. ana_2.wav1.002. ana_2.wav1
3. ben_1.wav0.332. ana_2.wav0.3310
4. ben_2.wav0.352. ana_2.wav0.3481
5. cal_1.wav0.482. ana_2.wav0.4788
6. cal_2.wav0.452. ana_2.wav0.4478
1. ana_1.wav0.283. ben_1.wav0.2784
2. ana_2.wav0.333. ben_1.wav0.3310
3. ben_1.wav1.003. ben_1.wav1
4. ben_2.wav0.663. ben_1.wav0.6615
5. cal_1.wav0.463. ben_1.wav0.4587
6. cal_2.wav0.423. ben_1.wav0.4151
1. ana_1.wav0.324. ben_2.wav0.3230
2. ana_2.wav0.354. ben_2.wav0.3481
3. ben_1.wav0.664. ben_2.wav0.6615
4. ben_2.wav1.004. ben_2.wav1
5. cal_1.wav0.574. ben_2.wav0.5736
6. cal_2.wav0.504. ben_2.wav0.4951
1. ana_1.wav0.485. cal_1.wav0.4774
2. ana_2.wav0.485. cal_1.wav0.4788
3. ben_1.wav0.465. cal_1.wav0.4587
4. ben_2.wav0.575. cal_1.wav0.5736
5. cal_1.wav1.005. cal_1.wav1
6. cal_2.wav0.585. cal_1.wav0.5826
1. ana_1.wav0.416. cal_2.wav0.4109
2. ana_2.wav0.456. cal_2.wav0.4478
3. ben_1.wav0.426. cal_2.wav0.4151
4. ben_2.wav0.506. cal_2.wav0.4951
5. cal_1.wav0.586. cal_2.wav0.5826
6. cal_2.wav1.006. cal_2.wav1
Detection error tradeoff of the voice comparisonsHow many misses does each false-alarm rate cost — and where do the two errors balance?
View data
Miss rate (same speaker rejected)False alarm rate (different speakers accepted)
01
00.9167
00.8333
00.7500
00.6667
00.5833
00.5000
00.4167
00.3333
00.2500
00.1667
00.0833
00
0.33330
0.66670
Similarity of same-speaker and different-speaker pairsWhat is the smooth shape of a distribution, and how much does it depend on the bandwidth?
View data
PairCosine similarity
Same speaker0.7616
Different speakers0.2784
Different speakers0.3230
Different speakers0.4774
Different speakers0.4109
Different speakers0.3310
Different speakers0.3481
Different speakers0.4788
Different speakers0.4478
Same speaker0.6615
Different speakers0.4587
Different speakers0.4151
Different speakers0.5736
Different speakers0.4951
Same speaker0.5826

Assumptions

  • Voices identify people — Speaker embeddings are biometric data. This result is never sent to an AI provider; saved embeddings are marked biometric. Get consent before comparing other people's voices.
  • One speaker per file — Each file gets one embedding; a file with several voices is a blend of them. Use speaker diarization for conversations.
  • Recordings like VoxCeleb — The model learned from interview speech; shortest file 1.50 s.

Voices

pathSecondsVoice groupMost similar fileCosine similarityspeaker
media/aud3/ana_1.wav1.500V1ana_2.wav0.7616ana
media/aud3/ana_2.wav1.500V1ana_1.wav0.7616ana
media/aud3/ben_1.wav1.500V2ben_2.wav0.6615ben
media/aud3/ben_2.wav1.500V2ben_1.wav0.6615ben
media/aud3/cal_1.wav1.500V3cal_2.wav0.5826cal
media/aud3/cal_2.wav1.500V3cal_1.wav0.5826cal

Same speaker or not: every pair of files with a known speaker

MeasureValue
Target pairs (same speaker)3
Non-target pairs12
Mean similarity, same speaker0.6686
Mean similarity, different speakers0.4198
Equal error rate0
Minimum DCF (π = 0.01)0
Closest-file speaker accuracy1
  • ECAPA-TDNN speaker embeddings by SpeechBrain (Ravanelli et al. 2021), trained on VoxCeleb; 16 kHz mono, float64. Similarity is the cosine of two embeddings (1 = the same direction). Voice groups: average-linkage clustering of the embeddings. Speaker embeddings are biometric data: this result stays on this computer and is never sent to an AI provider.
The exact R script · R R version 4.5.1 (2025-06-13)
# Compare voices (speaker embeddings)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method audio.speakers 1.0.0 · spec 0256aeda2cef25d2
# Dataset: aud3_voices (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr) # cs_ecapa_* (ECAPA-TDNN), cs_diarize_ahc (grouping), cs_verif_* (EER, DCF)

# %% Audio files listed in the path column
PATH <- "path"
SPEAKER <- "speaker"
N_GROUPS <- NULL  # NULL: grouped by the similarity threshold
SIMILARITY <- 0.5
P_TARGET <- 0.01
DATA_DIR <- dirname(normalizePath("tests/parity/fixtures/aud3_voices.parquet"))
df <- nanoparquet::read_parquet("tests/parity/fixtures/aud3_voices.parquet", col_select = if (is.null(SPEAKER)) PATH else c(PATH, SPEAKER))
df <- as.data.frame(df)
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.speakers/voices-known-speakers/out-r", df,
                        "tests/parity/fixtures/aud3_voices.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)
ids_for <- ifelse(is.na(paths), NA_character_, media_ids)
status <- cs_media_status(media, ids_for)
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) < 2) cs_error("CS_E_TOO_FEW_ROWS", what = "Comparing voices", min = 2, 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]]))

# %% Speaker embeddings (ECAPA-TDNN, float64 on one thread: the Parity profile). Biometric: kept out of AI.
torch::torch_set_num_threads(1L)
model <- cs_ecapa_load(cs_ecapa_locate())
progress <- cs_progress(sprintf("Embedding %d voices", length(ok)), total = length(ok))
secs <- numeric(length(ok))
E <- matrix(0, nrow = length(ok), ncol = as.integer(model$config$lin_neurons))
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_ecapa_embed(model, list(clip))[1, ]
  cs_progress_update(progress, k)
}
cs_progress_done(progress)
S <- cs_ecapa_cosine(E, E)

# %% Voice groups (average linkage on cosine distance) and each file's closest other file
labels <- cs_diarize_ahc(E, n_speakers = N_GROUPS, similarity = SIMILARITY, max_speakers = length(ok))
n_groups <- max(labels) + 1L
names_ <- basename(paths[ok])
near <- character(length(ok))
near_sim <- numeric(length(ok))
for (k in seq_along(ok)) {
  row <- S[k, ]
  row[k] <- -Inf
  j <- which.max(row)
  near[k] <- names_[j]
  near_sim[k] <- S[k, j]
}

# %% Known speakers: every pair of files is a trial (same speaker or not)
spk <- NULL
trial <- NULL
nn_acc <- NULL
if (!is.null(SPEAKER)) {
  spk <- as.character(df[[SPEAKER]])
  lab <- spk[ok]
  # Every pair a < b of files whose speakers are known, in the order a, then b, built in one pass (growing the two
  # vectors pair by pair copied them once per pair: hours at the row cap).
  k <- length(ok)
  pa <- rep.int(seq_len(k), k - seq_len(k))
  pb <- as.integer(unlist(lapply(seq_len(k), function(a) if (a < k) (a + 1L):k else integer(0)), use.names = FALSE))
  known <- !is.na(lab[pa]) & !is.na(lab[pb])
  pa <- pa[known]
  pb <- pb[known]
  sc <- as.numeric(S[cbind(pa, pb)])
  same <- lab[pa] == lab[pb]
  if (any(same) && any(!same)) {
    trial <- cs_verif_summary(sc, same, P_TARGET, 1, 1, "linear")
    trial$mean_target <- mean(sc[same])
    trial$mean_nontarget <- mean(sc[!same])
    trial$pts <- cs_verif_det_points(sc, same)
    trial$scores <- sc
    trial$same <- same
  } else {
    warnings <- c(warnings, "Known speakers need at least two files of one speaker and two different speakers for verification scores.")
  }
  hits <- 0L
  n_id <- 0L
  for (a in seq_along(ok)) {
    if (is.na(lab[a]) || sum(seq_along(ok) != a & !is.na(lab) & lab == lab[a]) == 0) next
    row <- vapply(seq_along(ok), function(b) if (b != a && !is.na(lab[b])) S[a, b] else -Inf, numeric(1))
    j <- which.max(row)
    hits <- hits + as.integer(lab[j] == lab[a])
    n_id <- n_id + 1L
  }
  nn_acc <- if (n_id > 0) hits / n_id else NULL
}

# %% Artifact: one row per embedded file (biometric — never shared with AI)
out <- cs_ml_out_dir("target/academy-parity/run-8142/audio.speakers/voices-known-speakers/out-r")
art <- data.frame(row = as.integer(ok - 1L), media_id = media_ids[ok], path = paths[ok], voice_group = sprintf("V%d", labels + 1L),
                  stringsAsFactors = FALSE)
for (d in seq_len(ncol(E))) art[[sprintf("emb_%d", d)]] <- E[, d]
nanoparquet::write_parquet(art, file.path(out, "speakers.parquet"))

# %% Assumptions
assumptions <- list(
  list(key = "biometric", label = "Voices identify people", status = "info",
       detail = "Speaker embeddings are biometric data. This result is never sent to an AI provider; saved embeddings are marked biometric. Get consent before comparing other people's voices."),
  list(key = "one_speaker", label = "One speaker per file", status = "info",
       detail = "Each file gets one embedding; a file with several voices is a blend of them. Use speaker diarization for conversations."),
  list(key = "domain", label = "Recordings like VoxCeleb", status = if (min(secs) < 1) "warn" else "pass",
       detail = paste0(sprintf("The model learned from interview speech; shortest file %.2f s", min(secs)),
                       if (min(secs) < 1) "; below about 1 s the embeddings are unreliable." else "."))
)

# %% 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), n_groups = n_groups,
               similarity_threshold = if (is.null(N_GROUPS)) SIMILARITY else NULL, mean_nearest_similarity = mean(near_sim), p_target = P_TARGET,
               n_target_trials = if (!is.null(trial)) as.integer(trial$n_target) else NULL,
               n_nontarget_trials = if (!is.null(trial)) as.integer(trial$n_nontarget) else NULL,
               mean_target_similarity = if (!is.null(trial)) trial$mean_target else NULL,
               mean_nontarget_similarity = if (!is.null(trial)) trial$mean_nontarget else NULL,
               eer = if (!is.null(trial)) trial$eer else NULL, min_dcf = if (!is.null(trial)) trial$min_dcf else NULL, nn_accuracy = nn_acc)
file_rows <- lapply(seq_along(ok), function(k) {
  r <- list(file = paths[ok[k]], seconds = secs[k], voice_group = sprintf("V%d", labels[k] + 1L), nearest = near[k], similarity = near_sim[k])
  if (!is.null(spk)) r$speaker <- spk[ok[k]]
  r
})
cols <- list(list(key = "file", label = PATH, type = "string"), list(key = "seconds", label = "Seconds", type = "number"),
             list(key = "voice_group", label = "Voice group", type = "string"), list(key = "nearest", label = "Most similar file", type = "string"),
             list(key = "similarity", label = "Cosine similarity", type = "number"))
if (!is.null(spk)) cols[[length(cols) + 1L]] <- list(key = "speaker", label = SPEAKER, type = "string")
tables <- list(list(key = "files", title = "Voices", columns = cols, rows = head(file_rows, 500),
                    note = if (length(file_rows) > 500) "First 500 files." else NULL))
if (!is.null(trial)) tables[[length(tables) + 1L]] <- list(key = "verification", title = "Same speaker or not: every pair of files with a known speaker",
  columns = list(list(key = "measure", label = "Measure", type = "string"), list(key = "value", label = "Value", type = "number")),
  rows = list(list(measure = "Target pairs (same speaker)", value = trial$n_target),
              list(measure = "Non-target pairs", value = trial$n_nontarget),
              list(measure = "Mean similarity, same speaker", value = trial$mean_target),
              list(measure = "Mean similarity, different speakers", value = trial$mean_nontarget),
              list(measure = "Equal error rate", value = trial$eer),
              list(measure = sprintf("Minimum DCF (π = %s)", format(P_TARGET)), value = trial$min_dcf),
              list(measure = "Closest-file speaker accuracy", value = nn_acc)))
m <- min(length(ok), 40L)
lv <- sprintf("%d. %s", seq_len(m), names_[seq_len(m)])
ia <- rep(seq_len(m), each = m)
ib <- rep(seq_len(m), times = m)
charts <- list(cs_chart("similarity", "matrix-heatmap", paste0("Voice similarity (cosine)", if (length(ok) > 40) " — first 40 files" else ""), list(
  row = cs_col("File", lv[ia], "categorical", levels = lv),
  col = cs_col("File", lv[ib], "categorical", levels = lv),
  value = cs_col("Cosine similarity", S[cbind(ia, ib)]),
  label = cs_col("Similarity", sprintf("%.2f", S[cbind(ia, ib)]), "categorical")),
  controls = list(scale = "sequential")))
scores_note <- list()
if (!is.null(trial)) {
  pts <- trial$pts
  inner <- which(is.finite(pts$threshold))
  keep <- inner[cs_verif_thin(length(inner))]
  charts[[length(charts) + 1L]] <- cs_chart("det", "det-curve", "Detection error tradeoff of the voice comparisons", list(
    fpr = cs_col("False alarm rate (different speakers accepted)", pts$fpr[keep]),
    fnr = cs_col("Miss rate (same speaker rejected)", pts$fnr[keep])),
    controls = list(eer = trial$eer, minDcf = trial$min_dcf, minDcfFpr = trial$min_dcf_fpr, minDcfFnr = trial$min_dcf_fnr))
  # Every pair up to 20,000; above that a seeded sample within each kind of pair (Python draws the same pairs). The EER,
  # detection costs and DET curve above use every pair.
  shown <- cs_verif_chart_sample(trial$same, 20000L, seed = 1L)
  n_pairs <- length(trial$same)
  big <- function(x) formatC(x, format = "d", big.mark = ",")
  if (length(shown) < n_pairs) scores_note <- list(paste0(sprintf("The similarity chart draws a seeded sample of %s of the %s pairs (the rarer kind keeps ",
                                                                  big(length(shown)), big(n_pairs)),
    "up to half of it, so both curves keep their shape; the same pairs in Python and R). The equal error rate, ",
    "the detection costs and the DET curve use every pair."))
  charts[[length(charts) + 1L]] <- cs_chart("scores", "density", paste0("Similarity of same-speaker and different-speaker pairs",
    if (length(shown) < n_pairs) sprintf(" — a sample of %s of %s pairs", big(length(shown)), big(n_pairs)) else ""), list(
    x = cs_col("Cosine similarity", trial$scores[shown]),
    group = cs_col("Pair", ifelse(trial$same[shown], "Same speaker", "Different speakers"), "categorical", levels = c("Different speakers", "Same speaker"))),
    controls = list(compare = FALSE))
}
summary <- paste0(sprintf("%d recordings were turned into %d-value speaker embeddings and fell into %d voice group%s", length(ok), ncol(E),
                          n_groups, if (n_groups != 1) "s" else ""),
                  if (is.null(N_GROUPS)) sprintf(" at cosine similarity %s.", format(SIMILARITY)) else " (the number asked for).")
if (!is.null(trial) && !is.null(nn_acc)) summary <- paste(summary, sprintf(
  "Among %d same-speaker and %d different-speaker pairs, the equal error rate was %.1f%% and the closest other file had the same speaker %.0f%% of the time.",
  as.integer(trial$n_target), as.integer(trial$n_nontarget), 100 * trial$eer, 100 * nn_acc))
statistics <- list(list(key = "n_groups", label = "Voice groups", value = n_groups, format = "integer"),
                   list(key = "mean_nearest_similarity", label = "Mean similarity to the closest file", value = values$mean_nearest_similarity))
if (!is.null(trial)) statistics[[length(statistics) + 1L]] <- list(key = "eer", label = "EER", value = trial$eer, format = "percent")
cs_publish(list(
  method = "audio.speakers",
  methodVersion = "1.0.0",
  title = "Speaker embeddings",
  engine = cs_engine_info("torch", "nanoparquet"),
  n = length(ok),
  biometric = TRUE,
  summary = summary,
  statistics = statistics,
  tables = tables,
  assumptions = assumptions,
  warnings = as.list(warnings),
  notes = c(list(paste0("ECAPA-TDNN speaker embeddings by SpeechBrain (Ravanelli et al. 2021), trained on VoxCeleb; 16 kHz mono, float64. ",
                        "Similarity is the cosine of two embeddings (1 = the same direction). Voice groups: average-linkage clustering of the ",
                        "embeddings. Speaker embeddings are biometric data: this result stays on this computer and is never sent to an AI provider.")),
            scores_note),
  charts = charts,
  artifacts = list(list(key = "speakers", path = file.path(out, "speakers.parquet"), format = "parquet", biometric = TRUE)),
  values = values
))
Python

6 recordings were turned into 192-value speaker embeddings and fell into 3 voice groups at cosine similarity 0.5. Among 3 same-speaker and 12 different-speaker pairs, the equal error rate was 0.0% and the closest other file had the same speaker 100% of the time.

Voice groups
3
Mean similarity to the closest file
0.6686
EER
0.0%

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Voices identify people — Speaker embeddings are biometric data. This result is never sent to an AI provider; saved embeddings are marked biometric. Get consent before comparing other people's voices.
  • One speaker per file — Each file gets one embedding; a file with several voices is a blend of them. Use speaker diarization for conversations.
  • Recordings like VoxCeleb — The model learned from interview speech; shortest file 1.50 s.

Voices

pathSecondsVoice groupMost similar fileCosine similarityspeaker
media/aud3/ana_1.wav1.500V1ana_2.wav0.7616ana
media/aud3/ana_2.wav1.500V1ana_1.wav0.7616ana
media/aud3/ben_1.wav1.500V2ben_2.wav0.6615ben
media/aud3/ben_2.wav1.500V2ben_1.wav0.6615ben
media/aud3/cal_1.wav1.500V3cal_2.wav0.5826cal
media/aud3/cal_2.wav1.500V3cal_1.wav0.5826cal

Same speaker or not: every pair of files with a known speaker

MeasureValue
Target pairs (same speaker)3
Non-target pairs12
Mean similarity, same speaker0.6686
Mean similarity, different speakers0.4198
Equal error rate0
Minimum DCF (π = 0.01)0
Closest-file speaker accuracy1
  • ECAPA-TDNN speaker embeddings by SpeechBrain (Ravanelli et al. 2021), trained on VoxCeleb; 16 kHz mono, float64. Similarity is the cosine of two embeddings (1 = the same direction). Voice groups: average-linkage clustering of the embeddings. Speaker embeddings are biometric data: this result stays on this computer and is never sent to an AI provider.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Compare voices (speaker embeddings)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method audio.speakers 1.0.0 · spec 0256aeda2cef25d2
# Dataset: aud3_voices (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 diarize as dz  # average-linkage grouping (twin: codesplashr cs_diarize_*)
from codesplash.audio import ecapa  # ECAPA-TDNN speaker embeddings (twin: codesplashr cs_ecapa_*)
from codesplash.evaluate import verification as vf  # EER and DCF of the trials (twin: codesplashr cs_verif_*)

# %% Audio files listed in the path column
PATH = "path"
SPEAKER = "speaker"
N_GROUPS = None  # None: grouped by the similarity threshold
SIMILARITY = 0.5
P_TARGET = 0.01
DATA_DIR = os.path.dirname(os.path.abspath("tests/parity/fixtures/aud3_voices.parquet"))
df = pd.read_parquet("tests/parity/fixtures/aud3_voices.parquet", columns=[PATH] if SPEAKER is None else [PATH, SPEAKER])
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.speakers/voices-known-speakers/out-python", df, "tests/parity/fixtures/aud3_voices.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) < 2:
    cs.cs_error("CS_E_TOO_FEW_ROWS", what="Comparing voices", min=2, 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]]}).")

# %% Speaker embeddings (ECAPA-TDNN, float64 on one thread: the Parity profile). Biometric: kept out of AI.
torch.set_num_threads(1)
model = ecapa.load(ecapa.locate())
progress = cs.progress(f"Embedding {len(ok)} voices", total=len(ok))
clips, E = [], np.zeros((len(ok), int(model["config"]["lin_neurons"])))
for k, i in enumerate(ok):
    clip = np.asarray(cs_media.audio(media, [media_ids[i]])[0], dtype=np.float64)
    clips.append(clip.size / 16000.0)
    E[k] = ecapa.embed(model, [clip])[0]
    progress.update(k + 1)
progress.done()
S = ecapa.cosine(E, E)

# %% Voice groups (average linkage on cosine distance) and each file's closest other file
labels = dz.ahc(E, n_speakers=N_GROUPS, similarity=SIMILARITY, max_speakers=len(ok))
n_groups = int(labels.max()) + 1
names = [os.path.basename(paths[i]) for i in ok]
near, near_sim = [], []
for k in range(len(ok)):
    row = S[k].copy()
    row[k] = -np.inf
    j = int(np.argmax(row))
    near.append(names[j])
    near_sim.append(float(S[k, j]))

# %% Known speakers: every pair of files is a trial (same speaker or not)
spk = None
trial = None
nn_acc = None
if SPEAKER is not None:
    spk = [None if pd.isna(v) else str(v) for v in df[SPEAKER].tolist()]  # None, NaN, pd.NA: unknown speaker
    lab = [spk[i] for i in ok]
    # Every pair a < b of files whose speakers are known, in the order a, then b, built in one pass (a loop over the
    # pairs held two Python lists of them: about 80 bytes and one interpreter step per pair at the row cap).
    levels = {}
    code = np.array([-1 if v is None else levels.setdefault(v, len(levels)) for v in lab], dtype=np.int64)
    pa, pb = np.triu_indices(len(ok), 1)
    known = (code[pa] >= 0) & (code[pb] >= 0)
    pa, pb = pa[known], pb[known]
    sc = np.asarray(S[pa, pb], dtype=np.float64)
    same = code[pa] == code[pb]
    del pa, pb, known
    if same.any() and (~same).any():
        trial = vf.summary(sc, same, P_TARGET, 1.0, 1.0, "linear")
        trial["mean_target"] = float(sc[same].mean())
        trial["mean_nontarget"] = float(sc[~same].mean())
        trial["pts"] = vf.det_points(sc, same)
        trial["scores"], trial["same"] = sc, same
    else:
        warnings.append("Known speakers need at least two files of one speaker and two different speakers for verification scores.")
    hits, n_id = 0, 0
    for a in range(len(ok)):
        if lab[a] is None or sum(1 for b in range(len(ok)) if b != a and lab[b] == lab[a]) == 0:
            continue
        row = np.array([S[a, b] if (b != a and lab[b] is not None) else -np.inf for b in range(len(ok))])
        j = int(np.argmax(row))
        hits += int(lab[j] == lab[a])
        n_id += 1
    nn_acc = hits / n_id if n_id else None

# %% Artifact: one row per embedded file (biometric — never shared with AI)
out = csml.out_dir("target/academy-parity/run-8142/audio.speakers/voices-known-speakers/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],
                    "voice_group": [f"V{g + 1}" for g in labels]})
for d in range(E.shape[1]):
    art[f"emb_{d + 1}"] = E[:, d]
art.to_parquet(os.path.join(out, "speakers.parquet"), index=False)

# %% Assumptions
assumptions = [
    {"key": "biometric", "label": "Voices identify people", "status": "info",
     "detail": "Speaker embeddings are biometric data. This result is never sent to an AI provider; saved embeddings are marked biometric. Get consent before comparing other people's voices."},
    {"key": "one_speaker", "label": "One speaker per file", "status": "info",
     "detail": "Each file gets one embedding; a file with several voices is a blend of them. Use speaker diarization for conversations."},
    {"key": "domain", "label": "Recordings like VoxCeleb", "status": "warn" if min(clips) < 1.0 else "pass",
     "detail": f"The model learned from interview speech; shortest file {min(clips):.2f} s" + ("; below about 1 s the embeddings are unreliable." if min(clips) < 1.0 else ".")},
]

# %% Result
f3 = lambda v: "—" if v is None else f"{v:.3f}"
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(clips)), "dim": int(E.shape[1]), "n_groups": n_groups, "similarity_threshold": SIMILARITY if N_GROUPS is None else None,
          "mean_nearest_similarity": float(np.mean(near_sim)), "p_target": P_TARGET,
          "n_target_trials": int(trial["n_target"]) if trial else None, "n_nontarget_trials": int(trial["n_nontarget"]) if trial else None,
          "mean_target_similarity": trial["mean_target"] if trial else None, "mean_nontarget_similarity": trial["mean_nontarget"] if trial else None,
          "eer": trial["eer"] if trial else None, "min_dcf": trial["min_dcf"] if trial else None, "nn_accuracy": nn_acc}
file_rows = []
for k, i in enumerate(ok):
    r = {"file": paths[i], "seconds": clips[k], "voice_group": f"V{labels[k] + 1}", "nearest": near[k], "similarity": near_sim[k]}
    if spk is not None:
        r["speaker"] = spk[i]
    file_rows.append(r)
cols = [{"key": "file", "label": PATH, "type": "string"}, {"key": "seconds", "label": "Seconds", "type": "number"},
        {"key": "voice_group", "label": "Voice group", "type": "string"}, {"key": "nearest", "label": "Most similar file", "type": "string"},
        {"key": "similarity", "label": "Cosine similarity", "type": "number"}]
if spk is not None:
    cols.append({"key": "speaker", "label": SPEAKER, "type": "string"})
tables = [{"key": "files", "title": "Voices", "columns": cols, "rows": file_rows[:500], "note": "First 500 files." if len(file_rows) > 500 else None}]
if trial:
    tables.append({"key": "verification", "title": "Same speaker or not: every pair of files with a known speaker",
                   "columns": [{"key": "measure", "label": "Measure", "type": "string"}, {"key": "value", "label": "Value", "type": "number"}],
                   "rows": [{"measure": "Target pairs (same speaker)", "value": trial["n_target"]},
                            {"measure": "Non-target pairs", "value": trial["n_nontarget"]},
                            {"measure": "Mean similarity, same speaker", "value": trial["mean_target"]},
                            {"measure": "Mean similarity, different speakers", "value": trial["mean_nontarget"]},
                            {"measure": "Equal error rate", "value": trial["eer"]},
                            {"measure": f"Minimum DCF (π = {P_TARGET:g})", "value": trial["min_dcf"]},
                            {"measure": "Closest-file speaker accuracy", "value": nn_acc}]})
charts = []
m = min(len(ok), 40)
lv = [f"{k + 1}. {names[k]}" for k in range(m)]
charts.append(cs.chart("similarity", "matrix-heatmap", "Voice similarity (cosine)" + (" — first 40 files" if len(ok) > 40 else ""), {
    "row": cs.col("File", [lv[a] for a in range(m) for _ in range(m)], "categorical", levels=lv),
    "col": cs.col("File", [lv[b] for _ in range(m) for b in range(m)], "categorical", levels=lv),
    "value": cs.col("Cosine similarity", [float(S[a, b]) for a in range(m) for b in range(m)]),
    "label": cs.col("Similarity", [f"{S[a, b]:.2f}" for a in range(m) for b in range(m)], "categorical")},
    controls={"scale": "sequential"}))
scores_note = []
if trial:
    pts = trial["pts"]
    inner = [i for i in range(pts["threshold"].size) if np.isfinite(pts["threshold"][i])]
    keep = [inner[j] for j in vf.thin(len(inner))]
    charts.append(cs.chart("det", "det-curve", "Detection error tradeoff of the voice comparisons", {
        "fpr": cs.col("False alarm rate (different speakers accepted)", [float(pts["fpr"][i]) for i in keep]),
        "fnr": cs.col("Miss rate (same speaker rejected)", [float(pts["fnr"][i]) for i in keep])},
        controls={"eer": trial["eer"], "minDcf": trial["min_dcf"], "minDcfFpr": trial["min_dcf_fpr"], "minDcfFnr": trial["min_dcf_fnr"]}))
    # Every pair up to 20,000; above that a seeded sample within each kind of pair (R draws the same pairs). The EER,
    # detection costs and DET curve above use every pair.
    shown = vf.chart_sample(trial["same"], 20000, seed=1)
    n_pairs = int(trial["same"].size)
    if shown.size < n_pairs:
        scores_note.append(f"The similarity chart draws a seeded sample of {shown.size:,} of the {n_pairs:,} pairs (the rarer kind keeps "
                           "up to half of it, so both curves keep their shape; the same pairs in Python and R). The equal error rate, "
                           "the detection costs and the DET curve use every pair.")
    charts.append(cs.chart("scores", "density", "Similarity of same-speaker and different-speaker pairs"
                           + (f" — a sample of {shown.size:,} of {n_pairs:,} pairs" if shown.size < n_pairs else ""), {
        "x": cs.col("Cosine similarity", [float(v) for v in trial["scores"][shown]]),
        "group": cs.col("Pair", ["Same speaker" if t else "Different speakers" for t in trial["same"][shown]], "categorical",
                        levels=["Different speakers", "Same speaker"])},
        controls={"compare": False}))
summary = (f"{len(ok)} recordings were turned into {E.shape[1]}-value speaker embeddings and fell into {n_groups} voice "
           f"group{'s' if n_groups != 1 else ''}" + (f" at cosine similarity {SIMILARITY:g}." if N_GROUPS is None else " (the number asked for)."))
if trial:
    summary += (f" Among {trial['n_target']} same-speaker and {trial['n_nontarget']} different-speaker pairs, the equal error rate was "
                f"{100 * trial['eer']:.1f}% and the closest other file had the same speaker {100 * nn_acc:.0f}% of the time." if nn_acc is not None else "")
cs.publish({
    "method": "audio.speakers",
    "methodVersion": "1.0.0",
    "title": "Speaker embeddings",
    "engine": cs.engine_info("numpy", "torch"),
    "n": len(ok),
    "biometric": True,
    "summary": summary,
    "statistics": [{"key": "n_groups", "label": "Voice groups", "value": n_groups, "format": "integer"},
                   {"key": "mean_nearest_similarity", "label": "Mean similarity to the closest file", "value": values["mean_nearest_similarity"]}]
                  + ([{"key": "eer", "label": "EER", "value": trial["eer"], "format": "percent"}] if trial else []),
    "tables": tables,
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": ["ECAPA-TDNN speaker embeddings by SpeechBrain (Ravanelli et al. 2021), trained on VoxCeleb; 16 kHz mono, float64. "
              "Similarity is the cosine of two embeddings (1 = the same direction). Voice groups: average-linkage clustering of the "
              "embeddings. Speaker embeddings are biometric data: this result stays on this computer and is never sent to an AI provider."]
             + scores_note,
    "charts": charts,
    "artifacts": [{"key": "speakers", "path": os.path.join(out, "speakers.parquet"), "format": "parquet", "biometric": True}],
    "values": values,
})

Compare voices (speaker embeddings) runs ECAPA-TDNN, from SpeechBrain's VoxCeleb weights written out in Python and R. It compares every pair by cosine, groups similar voices and, with a known speaker column, scores every pair as a same-or-different trial. On six clips of three synthetic voices the equal error rate is 0.0%: every same-voice pair is closer than every different-voice pair, which real recordings rarely manage.

A speaker embedding identifies a person: it is biometric dataBiometric dataData that can identify a person by their body or behavior, such as a speaker embedding. It never goes to an AI provider.. The result never goes to an AI provider, saved embeddings are marked biometric, and Erase everywhere lists them. Get consent before comparing other people's voices, and keep enrollmentSpeaker enrollmentKnown audio of a speaker used to build a profile that later recordings are compared with. It must never overlap the test audio. audio out of any test.

05

Scoring trials

Read
Verification scoresRecorded · Python and R agreeRecorded 2026-11-25 · 25 values compared
R

On 120 target and 480 non-target trials, the equal error rate was 2.50% (95% CI 1.25% to 3.75%) and the minimum detection cost 0.308 at π = 0.01, C_miss = 1, C_fa = 1.

EER
2.5%
Minimum DCF
0.3083
Miss rate at 1% false alarms
14.2%

Plots

Detection error tradeoff: miss rate against false alarm rateHow many misses does each false-alarm rate cost — and where do the two errors balance?
View data
Miss rate (false rejects)False alarm rate (false accepts)Trials
01All trials
00.9979All trials
00.9958All trials
00.9938All trials
00.9917All trials
00.9896All trials
00.9875All trials
00.9854All trials
00.9833All trials
00.9812All trials
00.9792All trials
00.9771All trials
00.9750All trials
00.9729All trials
00.9708All trials
00.9667All trials
00.9646All trials
00.9625All trials
00.9604All trials
00.9583All trials
00.9542All trials
00.9521All trials
00.9500All trials
00.9479All trials
00.9458All trials
00.9437All trials
00.9417All trials
00.9396All trials
00.9375All trials
00.9333All trials
00.9292All trials
00.9229All trials
00.9208All trials
00.9187All trials
00.9167All trials
00.9146All trials
00.9125All trials
00.9104All trials
00.9083All trials
00.9063All trials
00.9042All trials
00.9021All trials
00.9000All trials
00.8979All trials
00.8958All trials
00.8917All trials
00.8875All trials
00.8833All trials
00.8812All trials
00.8792All trials
00.8771All trials
00.8729All trials
00.8708All trials
00.8667All trials
00.8646All trials
00.8625All trials
00.8604All trials
00.8562All trials
00.8521All trials
00.8500All trials

First 60 of 393 rows.

Scores of target and non-target trialsWhat is the smooth shape of a distribution, and how much does it depend on the bandwidth?
View data
Trialcosine
Non-target0.2010
Non-target0.3850
Non-target0.3840
Non-target0.2920
Non-target0.1320
Target0.7800
Non-target0.0460
Non-target0.2990
Non-target0.1560
Target0.5810
Non-target0.1420
Target0.7880
Non-target0.2190
Non-target0.3400
Target0.6650
Non-target0.1770
Non-target0.2680
Non-target0.1140
Non-target0.1120
Non-target0.1060
Non-target0.0700
Non-target0.1600
Non-target0.0750
Target0.5230
Target0.7550
Non-target0.1600
Non-target0.0440
Non-target0.2420
Non-target0.2490
Non-target0.1260
Non-target0.2680
Non-target0.2330
Non-target0.1860
Non-target0.2620
Target0.7300
Target0.6190
Non-target0.0450
Non-target0.1300
Non-target0.1830
Non-target0.1420
Target0.6450
Non-target0.3110
Non-target0.2200
Non-target0.2510
Non-target0.2220
Non-target0.4550
Non-target0.2000
Non-target0.2160
Target0.7740
Target0.5580
Target0.7230
Target0.8650
Non-target0.2250
Non-target0.1050
Non-target0.2870
Target0.5110
Non-target0.1620
Non-target0.1110
Non-target0.1560
Non-target0.0790

First 60 of 600 rows.

Assumptions

  • Scores come from a fixed system — Fix the system and any threshold before scoring these trials. The minimum DCF picks its threshold on them, so it is optimistic; the actual DCF uses a threshold fixed in advance.
  • Trials are not independent — Trials that share a speaker or item are correlated, so intervals from resampling trials are narrower than a resampling of speakers would give.
  • Enough errors at the EER — About 3 misses and 12 false alarms at the EER; with fewer than 30 of either the rates are rough (Doddington's rule of 30).

Verification metrics (95% intervals from resampling trials)

MeasureValue95% CI low95% CI highThresholdFalse alarm rateMiss rate
Equal error rate (EER)0.02500.01250.03750.43600.02500.0250
Minimum DCF (threshold picked on these trials)0.30830.11670.38960.562000.3083

Miss rate at fixed false alarm rates

False alarm rate at mostMiss rateThreshold
0.00100.30830.5620
0.01000.14170.5020
0.05000.00830.3890
0.100000.3360
  • A trial is accepted when cosine ≥ the threshold; target trials: same = true. EER: linear interpolation on the operating points. DCF = C_miss·π·miss rate + C_fa·(1 − π)·false alarm rate, normalized by min(C_miss·π, C_fa·(1 − π)); π = 0.01. Intervals: 1000 resamples of trials within each class on the shared seeded stream (seed 42).
The exact R script · R R version 4.5.1 (2025-06-13)
# Evaluate verification scores (EER, DCF, DET)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method evaluate.verification 1.0.0 · spec b3990d6ff44d22ee
# Dataset: aud3_trials (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr) # cs_verif_* (DET points, EER, DCF, Cllr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/aud3_trials.parquet", col_select = c("cosine", "same")))
n_input <- nrow(df)
df[["same"]] <- factor(df[["same"]], levels = c("false", "true"))  # stored level order
df <- df[stats::complete.cases(df[c("cosine", "same")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("cosine", "same"))  # infinite values stop the run (registry/errors.yaml)

# %% Trials
sc <- "cosine"
lc <- "same"
gc <- NULL
present <- levels(df[[lc]])  # levels with data, in stored order
cs_check_groups(df[[lc]], lc, minimum = 2, exactly = 2)
target_level <- present[length(present)]  # default: the last level ("true")
s <- as.numeric(df[[sc]])
pos <- as.character(df[[lc]]) == target_level
p_target <- 0.01  # NULL: the share of target trials
c_miss <- 1
c_fa <- 1
eer_method <- "linear"  # linear | rocch
llr <- FALSE
fixed_threshold <- NULL
reps <- as.integer(1000)
conf <- 0.95
seed <- 42  # portable Wichmann-Hill stream: Python resamples the same trials

# %% Verification metrics
res <- cs_verif_summary(s, pos, p_target, c_miss, c_fa, eer_method, if (llr) NULL else fixed_threshold, llr)
ci <- cs_verif_bootstrap(s, pos, reps, seed, conf, p_target, c_miss, c_fa, eer_method)
pts <- cs_verif_det_points(s, pos)
prior <- res$prior
n_t <- res$n_target
n_n <- res$n_nontarget
op_rows <- lapply(c(0.001, 0.01, 0.05, 0.1), function(target) {
  o <- cs_verif_fnr_at_fpr(pts, target)
  list(fpr_target = target, fnr = o$fnr, threshold = o$threshold)
})
fnr_01 <- op_rows[[2]]$fnr

# %% Conditions
groups <- if (!is.null(gc)) levels(df[[gc]]) else character(0)
gcol <- if (!is.null(gc)) as.character(df[[gc]]) else NULL
g_rows <- list()
g_curves <- list()
for (lv in groups) {
  m <- gcol == lv
  nt <- sum(pos & m)
  nn <- sum(!pos & m)
  if (nt == 0 || nn == 0) {
    g_rows[[length(g_rows) + 1L]] <- list(group = lv, n_target = nt, n_nontarget = nn, eer = NULL, min_dcf = NULL)
    next
  }
  r <- cs_verif_summary(s[m], pos[m], p_target, c_miss, c_fa, eer_method)
  g_rows[[length(g_rows) + 1L]] <- list(group = lv, n_target = nt, n_nontarget = nn, eer = r$eer, min_dcf = r$min_dcf)
  if (length(g_curves) < 7) g_curves[[length(g_curves) + 1L]] <- list(name = lv, pts = cs_verif_det_points(s[m], pos[m]))
}

# %% Assumptions
e_t <- res$eer * n_t
e_n <- res$eer * n_n
few <- min(e_t, e_n) < 30
assumptions <- list(
  list(key = "held_out", label = "Scores come from a fixed system", status = "info",
       detail = "Fix the system and any threshold before scoring these trials. The minimum DCF picks its threshold on them, so it is optimistic; the actual DCF uses a threshold fixed in advance."),
  list(key = "independence", label = "Trials are not independent", status = "info",
       detail = "Trials that share a speaker or item are correlated, so intervals from resampling trials are narrower than a resampling of speakers would give."),
  list(key = "errors", label = "Enough errors at the EER", status = if (few) "warn" else "pass",
       detail = paste0(sprintf("About %.0f misses and %.0f false alarms at the EER", e_t, e_n),
                       if (few) "; with fewer than 30 of either the rates are rough (Doddington's rule of 30)." else "."))
)
if (res$eer > 0.5) warnings <- c(warnings, "The equal error rate is above 50%: higher scores go with different-source trials. Check the same-source level.")

# %% Result
pct <- sprintf("%.0f%%", conf * 100)
f3 <- function(v) if (is.null(v)) "—" else sprintf("%.3f", v)
fp <- function(v) if (is.null(v)) "—" else sprintf("%.2f%%", 100 * v)
values <- list(n = nrow(df), n_target = n_t, n_nontarget = n_n, target_level = target_level, p_target = prior,
               c_miss = c_miss, c_fa = c_fa, eer_method = eer_method,
               eer = res$eer, eer_low = ci$eer_low, eer_high = ci$eer_high, eer_threshold = res$eer_threshold,
               min_dcf = res$min_dcf, min_dcf_low = ci$min_dcf_low, min_dcf_high = ci$min_dcf_high,
               min_dcf_threshold = res$min_dcf_threshold, min_dcf_fpr = res$min_dcf_fpr, min_dcf_fnr = res$min_dcf_fnr,
               actual_threshold = res$actual_threshold, actual_dcf = res$actual_dcf, actual_fpr = res$actual_fpr,
               actual_fnr = res$actual_fnr, cllr = res$cllr, fnr_at_fpr_01 = fnr_01, n_groups = length(groups))
metric_rows <- list(
  list(measure = "Equal error rate (EER)", value = res$eer, low = ci$eer_low, high = ci$eer_high,
       threshold = res$eer_threshold, fpr = res$eer, fnr = res$eer),
  list(measure = "Minimum DCF (threshold picked on these trials)", value = res$min_dcf, low = ci$min_dcf_low,
       high = ci$min_dcf_high, threshold = res$min_dcf_threshold, fpr = res$min_dcf_fpr, fnr = res$min_dcf_fnr)
)
if (!is.null(res$actual_dcf)) metric_rows[[length(metric_rows) + 1L]] <- list(
  measure = if (llr) "Actual DCF (Bayes threshold)" else "Actual DCF (fixed threshold)", value = res$actual_dcf,
  low = NULL, high = NULL, threshold = res$actual_threshold, fpr = res$actual_fpr, fnr = res$actual_fnr)
if (!is.null(res$cllr)) metric_rows[[length(metric_rows) + 1L]] <- list(
  measure = "Cllr (bits)", value = res$cllr, low = NULL, high = NULL, threshold = NULL, fpr = NULL, fnr = NULL)
tables <- list(
  list(key = "metrics", title = sprintf("Verification metrics (%s intervals from resampling trials)", pct),
       columns = list(list(key = "measure", label = "Measure", type = "string"), list(key = "value", label = "Value", type = "number"),
                      list(key = "low", label = paste(pct, "CI low"), type = "number"), list(key = "high", label = paste(pct, "CI high"), type = "number"),
                      list(key = "threshold", label = "Threshold", type = "number"), list(key = "fpr", label = "False alarm rate", type = "number"),
                      list(key = "fnr", label = "Miss rate", type = "number")),
       rows = metric_rows),
  list(key = "operating_points", title = "Miss rate at fixed false alarm rates",
       columns = list(list(key = "fpr_target", label = "False alarm rate at most", type = "number"), list(key = "fnr", label = "Miss rate", type = "number"),
                      list(key = "threshold", label = "Threshold", type = "number")),
       rows = op_rows)
)
if (length(groups)) tables[[length(tables) + 1L]] <- list(key = "groups", title = sprintf("By %s", gc),
  columns = list(list(key = "group", label = gc, type = "string"), list(key = "n_target", label = "Target trials", type = "integer"),
                 list(key = "n_nontarget", label = "Non-target trials", type = "integer"), list(key = "eer", label = "EER", type = "number"),
                 list(key = "min_dcf", label = "Minimum DCF", type = "number")),
  rows = g_rows)
series <- c(list(list(name = "All trials", pts = pts)), g_curves)
det_f <- numeric(0)
det_m <- numeric(0)
det_s <- character(0)
for (se in series) {
  inner <- which(is.finite(se$pts$threshold))
  j <- inner[cs_verif_thin(length(inner))]
  det_f <- c(det_f, se$pts$fpr[j])
  det_m <- c(det_m, se$pts$fnr[j])
  det_s <- c(det_s, rep(se$name, length(j)))
}
charts <- list(cs_chart("det", "det-curve", "Detection error tradeoff: miss rate against false alarm rate", list(
  fpr = cs_col("False alarm rate (false accepts)", det_f),
  fnr = cs_col("Miss rate (false rejects)", det_m),
  model = cs_col("Trials", det_s, "categorical", levels = vapply(series, function(se) se$name, character(1)))),
  controls = list(eer = res$eer, minDcf = res$min_dcf, minDcfFpr = res$min_dcf_fpr, minDcfFnr = res$min_dcf_fnr,
                  actualDcf = res$actual_dcf, actualFpr = res$actual_fpr, actualFnr = res$actual_fnr)))
keep <- cs_verif_thin(nrow(df), 20000L)
charts[[length(charts) + 1L]] <- cs_chart("scores", "density", "Scores of target and non-target trials", list(
  x = cs_col(sc, s[keep]),
  group = cs_col("Trial", ifelse(pos[keep], "Target", "Non-target"), "categorical", levels = c("Non-target", "Target"))),
  controls = list(compare = FALSE))
summary <- sprintf("On %d target and %d non-target trials, the equal error rate was %s (%s CI %s to %s) and the minimum detection cost %s at π = %s, C_miss = %s, C_fa = %s.",
                   as.integer(n_t), as.integer(n_n), fp(res$eer), pct, fp(ci$eer_low), fp(ci$eer_high), f3(res$min_dcf),
                   format(prior, digits = 6), format(c_miss, digits = 6), format(c_fa, digits = 6))
if (!is.null(res$actual_dcf)) summary <- paste(summary, sprintf("At the %s threshold %s the actual cost was %s.",
  if (llr) "Bayes" else "fixed", formatC(res$actual_threshold, digits = 3, format = "g"), f3(res$actual_dcf)))
if (!is.null(res$cllr)) summary <- paste(summary, sprintf("Cllr = %.3f bits.", res$cllr))
cs_publish(list(
  method = "evaluate.verification",
  methodVersion = "1.0.0",
  title = "Verification scores",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = nrow(df),
  summary = summary,
  statistics = list(list(key = "eer", label = "EER", value = res$eer, format = "percent"),
                    list(key = "min_dcf", label = "Minimum DCF", value = res$min_dcf),
                    list(key = "fnr_at_fpr_01", label = "Miss rate at 1% false alarms", value = fnr_01, format = "percent")),
  tables = tables,
  assumptions = assumptions,
  warnings = warnings,
  notes = list(paste0(sprintf("A trial is accepted when %s ≥ the threshold; target trials: %s = %s. ", sc, lc, target_level),
                      sprintf("EER: %s. ", if (eer_method == "linear") "linear interpolation on the operating points" else "the crossing on the ROC convex hull"),
                      sprintf("DCF = C_miss·π·miss rate + C_fa·(1 − π)·false alarm rate, normalized by min(C_miss·π, C_fa·(1 − π)); π = %s", format(prior, digits = 6)),
                      if (is.null(p_target)) " (the share of target trials)." else ".",
                      sprintf(" Intervals: %d resamples of trials within each class on the shared seeded stream (seed %d).", reps, as.integer(seed)))),
  charts = charts,
  values = values
))
Python

On 120 target and 480 non-target trials, the equal error rate was 2.50% (95% CI 1.25% to 3.75%) and the minimum detection cost 0.308 at π = 0.01, C_miss = 1, C_fa = 1.

EER
2.5%
Minimum DCF
0.3083
Miss rate at 1% false alarms
14.2%

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Scores come from a fixed system — Fix the system and any threshold before scoring these trials. The minimum DCF picks its threshold on them, so it is optimistic; the actual DCF uses a threshold fixed in advance.
  • Trials are not independent — Trials that share a speaker or item are correlated, so intervals from resampling trials are narrower than a resampling of speakers would give.
  • Enough errors at the EER — About 3 misses and 12 false alarms at the EER; with fewer than 30 of either the rates are rough (Doddington's rule of 30).

Verification metrics (95% intervals from resampling trials)

MeasureValue95% CI low95% CI highThresholdFalse alarm rateMiss rate
Equal error rate (EER)0.02500.01250.03750.43600.02500.0250
Minimum DCF (threshold picked on these trials)0.30830.11670.38960.562000.3083

Miss rate at fixed false alarm rates

False alarm rate at mostMiss rateThreshold
0.00100.30830.5620
0.01000.14170.5020
0.05000.00830.3890
0.100000.3360
  • A trial is accepted when cosine ≥ the threshold; target trials: same = true. EER: linear interpolation on the operating points. DCF = C_miss·π·miss rate + C_fa·(1 − π)·false alarm rate, normalized by min(C_miss·π, C_fa·(1 − π)); π = 0.01. Intervals: 1000 resamples of trials within each class on the shared seeded stream (seed 42).
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Evaluate verification scores (EER, DCF, DET)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method evaluate.verification 1.0.0 · spec b3990d6ff44d22ee
# Dataset: aud3_trials (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import math

import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.errors import check_groups
from codesplash.evaluate import verification as vf  # DET points, EER, DCF, Cllr (twin: codesplashr cs_verif_*)

# %% Data
df = pd.read_parquet("tests/parity/fixtures/aud3_trials.parquet", columns=["cosine", "same"])
n_input = len(df)
df["same"] = pd.Categorical(df["same"], categories=["false", "true"])  # stored level order
df = df.dropna(subset=["cosine", "same"])  # listwise deletion over the analysis columns
df["same"] = df["same"].cat.remove_unused_categories()
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["cosine", "same"])  # infinite values stop the run (registry/errors.yaml)

# %% Trials
sc, lc = "cosine", "same"
gc = None
present = [str(v) for v in df[lc].cat.categories]  # levels with data, in stored order
check_groups(df[lc], lc, minimum=2, exactly=2)
target_level = present[-1]  # default: the last level ("true")
s = df[sc].to_numpy(dtype=float)
pos = (df[lc].astype(str) == target_level).to_numpy()
p_target = 0.01  # None: the share of target trials
c_miss, c_fa = 1, 1
eer_method = "linear"  # linear | rocch
llr = False
fixed_threshold = None
reps = int(1000)
conf = 0.95
seed = 42  # portable Wichmann–Hill stream: R resamples the same trials

# %% Verification metrics
res = vf.summary(s, pos, p_target, c_miss, c_fa, eer_method, None if llr else fixed_threshold, llr)
ci = vf.bootstrap(s, pos, reps, seed, conf, p_target, c_miss, c_fa, eer_method)
pts = vf.det_points(s, pos)
prior = res["prior"]
n_t, n_n = res["n_target"], res["n_nontarget"]
op_rows = []
for target in (0.001, 0.01, 0.05, 0.1):
    fnr_t, thr_t = vf.fnr_at_fpr(pts, target)
    op_rows.append({"fpr_target": target, "fnr": fnr_t, "threshold": thr_t})
fnr_01 = op_rows[1]["fnr"]

# %% Conditions
groups = [str(v) for v in df[gc].cat.categories] if gc else []
gcol = df[gc].astype(str).to_numpy() if gc else None
g_rows, g_curves = [], []
for lv in groups:
    m = gcol == lv
    nt, nn = int(np.sum(pos & m)), int(np.sum(~pos & m))
    if nt == 0 or nn == 0:
        g_rows.append({"group": lv, "n_target": nt, "n_nontarget": nn, "eer": None, "min_dcf": None})
        continue
    r = vf.summary(s[m], pos[m], p_target, c_miss, c_fa, eer_method)
    g_rows.append({"group": lv, "n_target": nt, "n_nontarget": nn, "eer": r["eer"], "min_dcf": r["min_dcf"]})
    if len(g_curves) < 7:
        g_curves.append((lv, vf.det_points(s[m], pos[m])))

# %% Assumptions
e_t, e_n = res["eer"] * n_t, res["eer"] * n_n
few = min(e_t, e_n) < 30
assumptions = [
    {"key": "held_out", "label": "Scores come from a fixed system", "status": "info",
     "detail": "Fix the system and any threshold before scoring these trials. The minimum DCF picks its threshold on them, so it is optimistic; the actual DCF uses a threshold fixed in advance."},
    {"key": "independence", "label": "Trials are not independent", "status": "info",
     "detail": "Trials that share a speaker or item are correlated, so intervals from resampling trials are narrower than a resampling of speakers would give."},
    {"key": "errors", "label": "Enough errors at the EER", "status": "warn" if few else "pass",
     "detail": f"About {e_t:.0f} misses and {e_n:.0f} false alarms at the EER" + ("; with fewer than 30 of either the rates are rough (Doddington's rule of 30)." if few else ".")},
]
if res["eer"] > 0.5:
    warnings.append("The equal error rate is above 50%: higher scores go with different-source trials. Check the same-source level.")

# %% Result
pct = f"{conf:.0%}"
f3 = lambda v: "—" if v is None else f"{v:.3f}"
fp = lambda v: "—" if v is None else f"{100 * v:.2f}%"
values = {"n": int(len(df)), "n_target": n_t, "n_nontarget": n_n, "target_level": target_level, "p_target": prior,
          "c_miss": c_miss, "c_fa": c_fa, "eer_method": eer_method,
          "eer": res["eer"], "eer_low": ci["eer_low"], "eer_high": ci["eer_high"], "eer_threshold": res["eer_threshold"],
          "min_dcf": res["min_dcf"], "min_dcf_low": ci["min_dcf_low"], "min_dcf_high": ci["min_dcf_high"],
          "min_dcf_threshold": res["min_dcf_threshold"], "min_dcf_fpr": res["min_dcf_fpr"], "min_dcf_fnr": res["min_dcf_fnr"],
          "actual_threshold": res["actual_threshold"], "actual_dcf": res["actual_dcf"], "actual_fpr": res["actual_fpr"],
          "actual_fnr": res["actual_fnr"], "cllr": res["cllr"], "fnr_at_fpr_01": fnr_01, "n_groups": len(groups)}
metric_rows = [
    {"measure": "Equal error rate (EER)", "value": res["eer"], "low": ci["eer_low"], "high": ci["eer_high"],
     "threshold": res["eer_threshold"], "fpr": res["eer"], "fnr": res["eer"]},
    {"measure": "Minimum DCF (threshold picked on these trials)", "value": res["min_dcf"], "low": ci["min_dcf_low"],
     "high": ci["min_dcf_high"], "threshold": res["min_dcf_threshold"], "fpr": res["min_dcf_fpr"], "fnr": res["min_dcf_fnr"]},
]
if res["actual_dcf"] is not None:
    metric_rows.append({"measure": "Actual DCF (Bayes threshold)" if llr else "Actual DCF (fixed threshold)", "value": res["actual_dcf"],
                        "low": None, "high": None, "threshold": res["actual_threshold"], "fpr": res["actual_fpr"], "fnr": res["actual_fnr"]})
if res["cllr"] is not None:
    metric_rows.append({"measure": "Cllr (bits)", "value": res["cllr"], "low": None, "high": None, "threshold": None, "fpr": None, "fnr": None})
tables = [
    {"key": "metrics", "title": f"Verification metrics ({pct} intervals from resampling trials)",
     "columns": [{"key": "measure", "label": "Measure", "type": "string"}, {"key": "value", "label": "Value", "type": "number"},
                 {"key": "low", "label": f"{pct} CI low", "type": "number"}, {"key": "high", "label": f"{pct} CI high", "type": "number"},
                 {"key": "threshold", "label": "Threshold", "type": "number"}, {"key": "fpr", "label": "False alarm rate", "type": "number"},
                 {"key": "fnr", "label": "Miss rate", "type": "number"}],
     "rows": metric_rows},
    {"key": "operating_points", "title": "Miss rate at fixed false alarm rates",
     "columns": [{"key": "fpr_target", "label": "False alarm rate at most", "type": "number"}, {"key": "fnr", "label": "Miss rate", "type": "number"},
                 {"key": "threshold", "label": "Threshold", "type": "number"}],
     "rows": op_rows},
]
if groups:
    tables.append({"key": "groups", "title": f"By {gc}",
                   "columns": [{"key": "group", "label": gc, "type": "string"}, {"key": "n_target", "label": "Target trials", "type": "integer"},
                               {"key": "n_nontarget", "label": "Non-target trials", "type": "integer"}, {"key": "eer", "label": "EER", "type": "number"},
                               {"key": "min_dcf", "label": "Minimum DCF", "type": "number"}],
                   "rows": g_rows})
series = [("All trials", pts)] + g_curves
det_f, det_m, det_s = [], [], []
for name, p in series:
    inner = [i for i in range(p["threshold"].size) if math.isfinite(p["threshold"][i])]
    for j in vf.thin(len(inner)):
        det_f.append(float(p["fpr"][inner[j]]))
        det_m.append(float(p["fnr"][inner[j]]))
        det_s.append(name)
charts = [cs.chart("det", "det-curve", "Detection error tradeoff: miss rate against false alarm rate", {
    "fpr": cs.col("False alarm rate (false accepts)", det_f),
    "fnr": cs.col("Miss rate (false rejects)", det_m),
    "model": cs.col("Trials", det_s, "categorical", levels=[name for name, _ in series])},
    controls={"eer": res["eer"], "minDcf": res["min_dcf"], "minDcfFpr": res["min_dcf_fpr"], "minDcfFnr": res["min_dcf_fnr"],
              "actualDcf": res["actual_dcf"], "actualFpr": res["actual_fpr"], "actualFnr": res["actual_fnr"]})]
keep = vf.thin(int(len(df)), 20000)
charts.append(cs.chart("scores", "density", "Scores of target and non-target trials", {
    "x": cs.col(sc, [float(s[i]) for i in keep]),
    "group": cs.col("Trial", ["Target" if pos[i] else "Non-target" for i in keep], "categorical", levels=["Non-target", "Target"])},
    controls={"compare": False}))
summary = (f"On {n_t} target and {n_n} non-target trials, the equal error rate was {fp(res['eer'])} ({pct} CI {fp(ci['eer_low'])} to {fp(ci['eer_high'])}) "
           f"and the minimum detection cost {f3(res['min_dcf'])} at π = {prior:g}, C_miss = {c_miss:g}, C_fa = {c_fa:g}.")
if res["actual_dcf"] is not None:
    summary += f" At the {'Bayes' if llr else 'fixed'} threshold {res['actual_threshold']:.3g} the actual cost was {f3(res['actual_dcf'])}."
if res["cllr"] is not None:
    summary += f" Cllr = {res['cllr']:.3f} bits."
cs.publish({
    "method": "evaluate.verification",
    "methodVersion": "1.0.0",
    "title": "Verification scores",
    "engine": cs.engine_info("pandas", "numpy"),
    "n": int(len(df)),
    "summary": summary,
    "statistics": [{"key": "eer", "label": "EER", "value": res["eer"], "format": "percent"},
                   {"key": "min_dcf", "label": "Minimum DCF", "value": res["min_dcf"]},
                   {"key": "fnr_at_fpr_01", "label": "Miss rate at 1% false alarms", "value": fnr_01, "format": "percent"}],
    "tables": tables,
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": [f"A trial is accepted when {sc} ≥ the threshold; target trials: {lc} = {target_level}. "
              f"EER: {'linear interpolation on the operating points' if eer_method == 'linear' else 'the crossing on the ROC convex hull'}. "
              f"DCF = C_miss·π·miss rate + C_fa·(1 − π)·false alarm rate, normalized by min(C_miss·π, C_fa·(1 − π)); π = {prior:g}"
              + (" (the share of target trials)." if p_target is None else ".")
              + f" Intervals: {reps} resamples of trials within each class on the shared seeded stream (seed {seed})."],
    "charts": charts,
    "values": values,
})

A trial pairs two recordings and a score; a target trial really is one speaker. At any threshold you trade misses against false alarms. The equal error rateEqual error rate (EER)The error rate at the threshold where false alarms and misses are equally common; 0 is perfect and 0.5 is guessing. is where they are equal: here 2.5% over 600 trials, with an interval from 1.3% to 3.8%.

The detection costDetection cost function (DCF)Cost of misses and false alarms at a threshold, weighted by their costs and the share of positives; 1 = no better than one fixed answer. prices errors at a stated target prior PtarP_{\text{tar}}:

Cdet⁡=CmissPtarPmiss+Cfa(1−Ptar)Pfa.C_{\det} = C_{\text{miss}} P_{\text{tar}} P_{\text{miss}} + C_{\text{fa}} (1 - P_{\text{tar}}) P_{\text{fa}}.

At Ptar=0.01P_{\text{tar}} = 0.01 the best threshold gives a normalized minimum cost of 0.308.

Reference · EVA046 · Runs in CodeSplashSpeaker verification EER and minimum detection costEvaluate whether speaker embeddings distinguish target-speaker from non-target trials.
06

Minimum cost and actual cost

Read

The minimum cost uses the best threshold found on the test trials: an optimistic number. A deployed system has to fix its threshold in advance. Fix it at a chosen score and you get the actual cost; at a target prior of 0.2 and the threshold 0.45, it is 0.108. The gap between actual and minimum cost measures how badly the threshold was set.

A cosine score is not a probability that two voices match. Turning scores into calibrated log-likelihood ratios takes separate development trials.

The same question applies to any score turned into a probability: see how bins and a fitted temperature change the reading.

HExplorable · How many bins? ECE and temperature scaling

The expected calibration error depends on how you bin. How much of a model's ECE is the bins talking, and can one temperature fix the model?

Score a perfectly calibrated model with these bins on these rows. What ECE will it get?

How sure?
2.00

The model's logits are this many times the truth's. Same model as Calibration and reliability.

1000

Half the rows fit the temperature; the other half score every ECE.

10

More bins see finer miscalibration but hold fewer rows each.

Bin edges

Equal-width bins split [0, 1] evenly; equal-count bins put the same number of predictions in each.

expected calibration error 0.100after T = 2.16 0.033perfect model 0.040

Blue dots are sized by how many rows fall in the bin. Gray dots are a perfectly calibrated model on the same rows: their distance from the diagonal is pure sampling noise, and it sets a floor under any calibration error you compute with these bins.

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

07

Move the threshold

Explore

HExplorable · The ROC curve and its threshold

What does moving a threshold trade away, and what does the AUC really measure?

How often does a random positive score above a random negative?

0.75
How sure?
1.50
2.50
0.100
150
threshold

Commit your prediction above to see the result

Make your prediction first; the figure appears when you commit.

Make your prediction to see the result.

Drag the threshold and watch the two error rates trade off; lower the prevalence and watch how many alarms are false. Verification is the same picture with "same speaker" as the positive class. An excellent EER can still hide poor behavior at very low false-alarm rates, the region a bank's voice login cares about.

08

Shortcuts that flatter

Predict

Predict first

In a test set, every recording of a speaker came from the same phone, and different speakers used different phones. A system reaches a very low EER. What do you conclude?

Trust the EERThe EER is likely too optimisticThe EER is likely too pessimistic
Reveal

Likely too optimistic. The system may be matching phones, not voices: a channel shortcut. Test with cross-channel trials, keep related recordings from the same session out of target pairs, and split by speaker. Trials also share speakers, so intervals that treat each trial as independent are too narrow.

09

Where it stands in CodeSplash

Read
EntryIn CodeSplash
x-vectors (AUD048)Explained here
ECAPA-TDNN (AUD049)Runs in CodeSplash (Experimental): Compare voices (speaker embeddings)
EER and detection cost (EVA046)Runs in CodeSplash: Evaluate verification scores (EER, minimum and actual cost, DET curve) for any table of trials

All three reference programs are component checks, verified in Python and R.

10

Check: speakers and verification

Checkpoint

Check yourself

What lets an x-vector network turn recordings of different lengths into one fixed-length vector?

Show the answer

Answer: b

Pooling over frames removes the time axis, whatever its length.

Check yourself

How are x-vector embeddings trained?

Show the answer

Answer: a

The classifier is discarded after training; the layer before it becomes the embedding for new voices.

Check yourself

What does the margin mm in ECAPA-TDNN's loss scos⁡(θy+m)s\cos(\theta_y + m) do?

Show the answer

Answer: b

Adding mm to the angle shrinks the true class's score during training, so the model must win by a gap on the sphere.

Check yourself

How does ECAPA-TDNN's pooling differ from the x-vector's?

Show the answer

Answer: b

Attentive statistics pooling computes a weighted mean and standard deviation.

Check yourself

With Cmiss=Cfa=1C_{\text{miss}} = C_{\text{fa}} = 1, Ptar=0.01P_{\text{tar}} = 0.01, a miss rate of 0.2 and a false-alarm rate of 0.01, what is the detection cost (before normalizing)?

Show the answer

Answer: 0.0119

0.01×0.2+0.99×0.01=0.002+0.0099=0.01190.01 \times 0.2 + 0.99 \times 0.01 = 0.002 + 0.0099 = 0.0119. Rare targets make false alarms dominate the cost.

Check yourself

Why is the minimum detection cost optimistic for a deployed system?

Show the answer

Answer: b

The actual cost at a threshold fixed beforehand is the honest number; the gap shows the cost of miscalibration.

Check yourself

Which test design gives the most trustworthy verification EER?

Show the answer

Answer: c

The other designs let the system match sessions, devices or identical audio instead of voices.

11

Recap

Recap
  • Speaker embeddings come from a speaker classifier's inner layer; statistics pooling handles any length.
  • ECAPA-TDNN adds attentive pooling and an angular margin; it runs in CodeSplash (Experimental).
  • EER and detection cost score trials; the minimum cost is optimistic, the actual cost at a fixed threshold is honest.
  • Watch for channel and session shortcuts; speaker embeddings are biometric data.

Concepts in this lesson