Skip to content

Whisper and multilingual speech systems

Whisper learned from web audio with imperfect transcripts and steers its decoder with task tokens. See how it fails, how word error rate scores it, and how SpeechT5, SeamlessM4T and MMS stretch speech models across tasks and languages.

Applied ~16 min11 steps

What runs in CodeSplash

You will be able to

  • Describe Whisper's weak supervision, log-mel encoder and task-token decoder
  • Recognize invented text on silence and repetition loops, and the settings that control them
  • Compute and read a word error rate, including its normalization policy
  • Compare SpeechT5, SeamlessM4T and MMS, and say why some weights can't ship

Read first

01

Trained on the web's transcripts

Read

WhisperWhisperOpenAI's speech-recognition model: an audio encoder and a text decoder trained on 680,000 hours of transcribed web audio. is an attention encoder–decoder trained on about 680,000 hours of audio paired with transcripts found on the web. Those transcripts are imperfect: subtitles that paraphrase, captions that skip words. That is weak supervisionWeak supervisionTraining with imperfect labels: coarse, indirect, noisy or written by rules. More of them doesn't remove a shared bias.: supervised learning at scale, with noisy labels.

The encoder reads 30-second log-mel windows. The decoder writes text tokens, steered by task tokensTask and language tokensSpecial tokens at the start of a decoder's prompt that pick the language and task, such as transcribe or translate, in Whisper-style models. at the start of its prompt: which language, transcribe or translate to English, with or without timestamps. One model covers many languages and two tasks.

Reference · AUD011 · Runs in CodeSplashWhisperA weakly supervised multilingual, multitask speech encoder–decoder trained on paired audio and text. It handles transcription and designated translation tasks using task/language tokens.
02

Its training loss, in one line

Read

Training is teacher-forced next-token prediction, conditioned on the audio and the task tokens cc:

L=−∑ulog⁡pθ(yu∣y<u,Mel(x),c).\mathcal{L} = -\sum_u \log p_\theta\bigl(y_u \mid y_{<u}, \mathrm{Mel}(x), c\bigr).

On the reference's toy table of token probabilities, that loss is 0.459. Nothing in it ties the output to time the way CTC's paths do, which is where Whisper's typical failures come from.

03

Run it

Read
Speech to text (Whisper)Recorded · Python and R agreeRecorded 2026-11-25 · 29 values compared
R

4 files (48.0 s) → 4 segments, 289 words; most common language en.

Files transcribed
4
Segments
4
Words
289
Mean log-probability
−0.2208

Plots

Segments over timeWho or what is active when — and where do they overlap?
View data
End (s)TextFileStart (s)Average log-probability
11And so my fellow Americans ask not what your country can do for you ask what you can do for your country.jfk.wav0−0.3321
2.500ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ahvowels.wav0−0.0561
11And so my fellow Americans ask not what your country can do for you ask what you can do for your country.jfk_long_8k.wav0−0.3195
32And so my fellow Americans ask not what your country can do for you ask what you can do for your country.jfk_long_8k.wav11−0.1754
Average log-probability of each segmentHow is one numeric variable distributed?
View data
Average log-probability per token
−0.3321
−0.0561
−0.3195
−0.1754

Assumptions

  • Text can be invented
  • Language from the first 30 seconds
  • One pass, no retries
  • Recordings of people

Transcripts

FileLanguageLength (s)SegmentsTranscript
jfk.waven111And so my fellow Americans ask not what your country can do for you ask what you can do for your country.
vowels.waven2.5001ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah …
quiet.waven1.5000
jfk_long_8k.waven332And so my fellow Americans ask not what your country can do for you ask what you can do for your country. And so my fellow Americans ask not what your country can do for you ask what you can do for your country.

Segments

FileStart (s)End (s)TextAvg log-probabilityNo-speech probability
jfk.wav011And so my fellow Americans ask not what your country can do for you ask what you can do for your country.−0.33210.0692
vowels.wav02.500ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah−0.05610.6014
jfk_long_8k.wav011And so my fellow Americans ask not what your country can do for you ask what you can do for your country.−0.31950.2623
jfk_long_8k.wav1132And so my fellow Americans ask not what your country can do for you ask what you can do for your country.−0.17540.1035
  • 1 rows have no file path and are left out.
  • 1 of 5 files couldn't be decoded, so their rows got missing values (first: aud2_speech/broken.wav).
The exact R script · R R version 4.5.1 (2025-06-13)
# Speech to text (Whisper)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method audio.transcribe 1.1.0 · spec d10f895fcf7fa3fc
# Dataset: aud2_speech (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Audio files listed in the path column
PATH <- "path"
REFERENCE <- NULL
MODEL <- "tiny"
LANGUAGE <- tolower(trimws(""))  # empty: detected per file
if (!nzchar(LANGUAGE)) LANGUAGE <- NULL
TASK <- "transcribe"
TIMESTAMPS <- TRUE
CONDITION <- TRUE
NO_SPEECH <- 0.6
LOGPROB <- -1
DATA_DIR <- dirname(normalizePath("tests/parity/fixtures/aud2_speech.parquet", mustWork = FALSE))
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/aud2_speech.parquet", col_select = c(PATH, REFERENCE)))
if (nrow(df) == 0) cs_error("CS_E_NO_ROWS")
if (!is.null(LANGUAGE) && !(LANGUAGE %in% cs_whisper_model_languages(MODEL))) {
  cs_error("CS_E_INVALID_OPTION", option = "language", allowed = "a language code Whisper knows (en, de, es, …) or empty", value = LANGUAGE)
}
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\":null,\"mono\":true,\"offset_seconds\":0,\"sample_rate\":16000}}", simplifyVector = FALSE), "target/academy-parity/run-98732/audio.transcribe/defaults_tiny/out-r", df,
                        "tests/parity/fixtures/aud2_speech.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 <- list()
ids_or_na <- vapply(seq_along(paths), function(i) if (is.na(paths[i]) || is.na(media_ids[i])) NA_character_ else as.character(media_ids[i]), "")
status <- cs_media_status(media, ifelse(is.na(paths), NA_character_, ids_or_na))
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)) {
  i <- unreadable[1]
  cs_error("CS_E_MEDIA_DECODE", file = paths[i], reason = status[i])
}
if (n_no_path > 0) warnings <- c(warnings, sprintf("%d rows have no file path and are left out.", n_no_path))

# %% Whisper (greedy decoding, 30-second windows; ADR 0101)
cs_deep_profile_configure(list(profile = "parity"))
model <- cs_whisper_load(cs_whisper_locate(MODEL))
files <- list(); segs <- list(); token_lists <- list()
first_failure <- NULL
for (k in seq_along(ok)) {
  i <- ok[k]
  # Outside the app the files are decoded here, so a bad file shows up now.
  clip <- tryCatch(cs_media_audio(media, media_ids[i])[[1]], cs_error = function(e) {
    if (!(e$code %in% c("CS_E_MEDIA_DECODE", "CS_E_MEDIA_UNSUPPORTED"))) stop(e)
    e
  })
  if (inherits(clip, "cs_error")) {
    unreadable <- c(unreadable, i)
    if (is.null(first_failure)) first_failure <- clip
    next
  }
  r <- cs_whisper_transcribe(model, clip, LANGUAGE, TASK, TIMESTAMPS, CONDITION, NO_SPEECH, LOGPROB)
  token_lists[[k]] <- r$tokens
  files[[k]] <- list(row = i - 1L, media_id = media_ids[i], path = paths[i], language = r$language, language_prob = r$language_prob,
                     duration_s = r$duration, segments = length(r$segments), text = r$text, windows = r$windows, skipped = r$skipped)
  for (j in seq_along(r$segments)) {
    s <- r$segments[[j]]
    segs[[length(segs) + 1L]] <- list(media_id = media_ids[i], path = paths[i], row = i - 1L, segment = j, start = s$start, end = s$end,
                                      text = s$text, avg_logprob = s$avg_logprob, no_speech_prob = s$no_speech_prob, language = r$language)
  }
}
if (!length(files)) stop(first_failure)
unreadable <- sort(unreadable)
if (length(unreadable)) {
  warnings <- c(warnings, cs_warning("CS_W_MEDIA_SKIPPED", count = length(unreadable), total = nrow(df) - n_no_path,
                                     file = paths[unreadable[1]]))
}
fcol <- function(x, key, type = "") vapply(x, function(e) e[[key]], type)

# %% Artifacts: one row per file (row-aligned with the input) and one row per timed segment
out <- cs_ml_out_dir("target/academy-parity/run-98732/audio.transcribe/defaults_tiny/out-r")
nanoparquet::write_parquet(data.frame(row = as.integer(fcol(files, "row", 1L)), text = fcol(files, "text", ""),
                                      language = fcol(files, "language", ""), stringsAsFactors = FALSE),
                           file.path(out, "transcripts.parquet"))
seg_df <- data.frame(
  media_id = fcol(segs, "media_id", ""), path = fcol(segs, "path", ""), row = as.integer(fcol(segs, "row", 1L)),
  segment = as.integer(fcol(segs, "segment", 1L)), start = fcol(segs, "start", 0), end = fcol(segs, "end", 0),
  text = fcol(segs, "text", ""), avg_logprob = fcol(segs, "avg_logprob", 0), no_speech_prob = fcol(segs, "no_speech_prob", 0),
  language = fcol(segs, "language", ""), stringsAsFactors = FALSE
)
nanoparquet::write_parquet(seg_df, file.path(out, "segments.parquet"))

# %% Result
lang_all <- fcol(files, "language", "")
langs <- table(lang_all)
lang_codes <- names(langs)
lang_n <- as.integer(langs)
ord <- order(-lang_n, lang_codes, method = "radix")
top_language <- lang_codes[ord[1]]
lp <- fcol(segs, "avg_logprob", 0)
texts <- fcol(files, "text", "")
values <- list(
  n_rows = nrow(df),
  n_files = nrow(df) - n_no_path,
  n_transcribed = length(files),
  n_unreadable = length(unreadable),
  n_no_path = n_no_path,
  audio_seconds = sum(fcol(files, "duration_s", 0)),
  speech_seconds = sum(fcol(segs, "end", 0) - fcol(segs, "start", 0)),
  n_segments = length(segs),
  n_windows = sum(fcol(files, "windows", 1L)),
  n_skipped_windows = sum(fcol(files, "skipped", 1L)),
  n_tokens = sum(lengths(token_lists)),
  n_words = sum(cs_whisper_word_count(texts)),
  token_check = cs_whisper_token_check(token_lists),
  mean_avg_logprob = if (length(lp)) mean(lp) else NULL,
  mean_no_speech_prob = if (length(segs)) mean(fcol(segs, "no_speech_prob", 0)) else NULL,
  n_low_confidence = sum(lp < LOGPROB),
  language = top_language,
  n_languages = length(lang_codes),
  model = MODEL,
  task = TASK
)
for (code in sort(lang_codes, method = "radix")) values[[sprintf("language[%s]", code)]] <- as.integer(langs[[code]])
for (k in seq_len(min(20L, length(files)))) {
  values[[sprintf("text[%d]", k)]] <- files[[k]]$text
  if (!is.null(files[[k]]$language_prob)) values[[sprintf("language_prob[%d]", k)]] <- files[[k]]$language_prob
}
short <- function(t) if (nchar(t) <= 600) t else paste0(substr(t, 1, 600), " …")
tables <- list(
  list(key = "transcripts", title = "Transcripts", columns = list(
    list(key = "file", label = "File", type = "string"), list(key = "language", label = "Language", type = "string"),
    list(key = "duration", label = "Length (s)", type = "number"), list(key = "segments", label = "Segments", type = "integer"),
    list(key = "text", label = "Transcript", type = "string")),
    rows = lapply(files, function(f) list(file = basename(f$path), language = f$language, duration = f$duration_s, segments = f$segments,
                                          text = short(f$text)))),
  list(key = "segments", title = if (length(segs) > 500) "Segments (first 500)" else "Segments", columns = list(
    list(key = "file", label = "File", type = "string"), list(key = "start", label = "Start (s)", type = "number"), list(key = "end", label = "End (s)", type = "number"),
    list(key = "text", label = "Text", type = "string"), list(key = "avg_logprob", label = "Avg log-probability", type = "number"),
    list(key = "no_speech_prob", label = "No-speech probability", type = "number")),
    rows = lapply(utils::head(segs, 500), function(s) list(file = basename(s$path), start = s$start, end = s$end, text = s$text,
                                                          avg_logprob = s$avg_logprob, no_speech_prob = s$no_speech_prob)))
)
charts <- list()
if (length(segs)) {
  lane_rows <- vapply(utils::head(files, 30), function(f) f$row, 1L)  # one lane per file, at most 30
  lanes <- unique(vapply(utils::head(files, 30), function(f) basename(f$path), ""))
  shown <- Filter(function(s) s$row %in% lane_rows, segs)
  charts[[length(charts) + 1L]] <- cs_chart("timeline", "segment-timeline", "Segments over time", list(
    start = cs_col("Start (s)", vapply(shown, function(s) s$start, 0), "numeric"),
    end = cs_col("End (s)", vapply(shown, function(s) s$end, 0), "numeric"),
    lane = cs_col("File", vapply(shown, function(s) basename(s$path), ""), "categorical", lanes),
    label = cs_col("Text", vapply(shown, function(s) s$text, ""), "categorical"),
    value = cs_col("Average log-probability", vapply(shown, function(s) s$avg_logprob, 0), "numeric")
  ), controls = list(labels = TRUE, overlap = FALSE))
}
if (length(lp)) {
  charts[[length(charts) + 1L]] <- cs_chart("confidence", "histogram", "Average log-probability of each segment",
                          list(x = cs_col("Average log-probability per token", lp, "numeric")), controls = list(scale = "count", kde = FALSE))
}
detected <- paste(sprintf("%s (%d)", lang_codes[ord], lang_n[ord]), collapse = ", ")
assumptions <- c(list(
  list(key = "hallucination", label = "Text can be invented", status = if (values$n_low_confidence > 0) "warn" else "info",
       message = if (values$n_low_confidence > 0) {
         sprintf("%d of %d segments have an average log-probability below %s: listen to them before relying on the text.",
                 values$n_low_confidence, length(segs), format(LOGPROB))
       } else {
         "No segment falls below the log-probability cutoff; Whisper can still mishear names and numbers."
       }),
  list(key = "language_detection", label = "Language from the first 30 seconds", status = "info",
       message = if (!is.null(LANGUAGE)) sprintf("Set to %s for every file.", LANGUAGE) else sprintf("Detected per file: %s.", detected)),
  list(key = "greedy_decoding", label = "One pass, no retries", status = "info",
       message = sprintf("%d windows decoded once each; %d skipped as silence.", values$n_windows, values$n_skipped_windows)),
  list(key = "speech_privacy", label = "Recordings of people", status = "info",
       message = "Transcripts stay on this computer. Get consent before transcribing other people's recordings.")
), cs_deep_profile_warning_rows())
cs_publish(list(
  title = "Speech to text (Whisper)",
  engine = cs_engine_info("torch", "safetensors", "jsonlite", "nanoparquet", "codesplashr"),
  n = length(files),
  summary = sprintf("%d files (%.1f s) → %d segments, %d words; most common language %s.", length(files), values$audio_seconds,
                    length(segs), values$n_words, top_language),
  statistics = list(
    list(key = "n_transcribed", label = "Files transcribed", value = length(files)),
    list(key = "n_segments", label = "Segments", value = length(segs)),
    list(key = "n_words", label = "Words", value = values$n_words),
    list(key = "mean_avg_logprob", label = "Mean log-probability", value = values$mean_avg_logprob)
  ),
  tables = tables,
  assumptions = assumptions,
  charts = charts,
  values = values,
  warnings = warnings,
  artifacts = list(list(key = "transcripts", path = file.path(out, "transcripts.parquet"), format = "parquet"),
                   list(key = "segments", path = file.path(out, "segments.parquet"), format = "parquet"))
))
Python

4 files (48.0 s) → 4 segments, 289 words; most common language en.

Files transcribed
4
Segments
4
Words
289
Mean log-probability
−0.2208

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

Assumptions

  • Text can be invented
  • Language from the first 30 seconds
  • One pass, no retries
  • Recordings of people

Transcripts

FileLanguageLength (s)SegmentsTranscript
jfk.waven111And so my fellow Americans ask not what your country can do for you ask what you can do for your country.
vowels.waven2.5001ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah …
quiet.waven1.5000
jfk_long_8k.waven332And so my fellow Americans ask not what your country can do for you ask what you can do for your country. And so my fellow Americans ask not what your country can do for you ask what you can do for your country.

Segments

FileStart (s)End (s)TextAvg log-probabilityNo-speech probability
jfk.wav011And so my fellow Americans ask not what your country can do for you ask what you can do for your country.−0.33210.0692
vowels.wav02.500ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah−0.05610.6014
jfk_long_8k.wav011And so my fellow Americans ask not what your country can do for you ask what you can do for your country.−0.31950.2623
jfk_long_8k.wav1132And so my fellow Americans ask not what your country can do for you ask what you can do for your country.−0.17540.1035
  • 1 rows have no file path and are left out.
  • 1 of 5 files couldn't be decoded, so their rows got missing values (first: aud2_speech/broken.wav).
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Speech to text (Whisper)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method audio.transcribe 1.1.0 · spec d10f895fcf7fa3fc
# Dataset: aud2_speech (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import os
from collections import Counter

import numpy as np
import pandas as pd

import codesplash as cs
from codesplash import ml as csml
from codesplash.audio import whisper as wh
from codesplash.deep import profile as cs_profile

# %% Audio files listed in the path column
PATH = "path"
REFERENCE = None
MODEL = "tiny"
LANGUAGE = "".strip().lower() or None  # empty: detected per file
TASK = "transcribe"
TIMESTAMPS = True
CONDITION = True
NO_SPEECH = 0.6
LOGPROB = -1
DATA_DIR = os.path.dirname(os.path.abspath("tests/parity/fixtures/aud2_speech.parquet"))
df = pd.read_parquet("tests/parity/fixtures/aud2_speech.parquet", columns=[PATH] if REFERENCE is None else [PATH, REFERENCE])
if not len(df):
    cs.cs_error("CS_E_NO_ROWS")
if LANGUAGE is not None and LANGUAGE not in wh.languages(MODEL):
    cs.cs_error("CS_E_INVALID_OPTION", option="language", allowed="a language code Whisper knows (en, de, es, …) or empty", value=LANGUAGE)
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\":null,\"mono\":true,\"offset_seconds\":0,\"sample_rate\":16000}}"), "target/academy-parity/run-98732/audio.transcribe/defaults_tiny/out-python", df, "tests/parity/fixtures/aud2_speech.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 n_no_path:
    warnings.append(f"{n_no_path} rows have no file path and are left out.")

# %% Whisper (greedy decoding, 30-second windows; ADR 0101)
cs_profile.configure({"profile": "parity"})
model = wh.load(wh.locate(MODEL))
progress = cs.progress(f"Transcribing {len(ok)} files with Whisper {MODEL}", total=len(ok))
files, segs, token_lists = [], [], []
first_failure = None
for k, i in enumerate(ok):
    try:
        clip = cs_media.audio(media, [media_ids[i]])[0]
    except cs.CsError as e:  # outside the app the files are decoded here, so a bad file shows up now
        if e.code not in ("CS_E_MEDIA_DECODE", "CS_E_MEDIA_UNSUPPORTED"):
            raise
        unreadable.append(i)
        first_failure = first_failure or e
        progress.update(k + 1)
        continue
    r = wh.transcribe(model, clip, LANGUAGE, TASK, TIMESTAMPS, CONDITION, NO_SPEECH, LOGPROB)
    token_lists.append(r["tokens"])
    files.append({"row": i, "media_id": media_ids[i], "path": paths[i], "language": r["language"], "language_prob": r["language_prob"],
                  "duration_s": r["duration"], "segments": len(r["segments"]), "text": r["text"], "windows": r["windows"], "skipped": r["skipped"]})
    for j, s in enumerate(r["segments"], start=1):
        segs.append({"media_id": media_ids[i], "path": paths[i], "row": i, "segment": j, "start": s["start"], "end": s["end"], "text": s["text"],
                     "avg_logprob": s["avg_logprob"], "no_speech_prob": s["no_speech_prob"], "language": r["language"]})
    progress.update(k + 1)
progress.done()
if not files:
    raise first_failure
unreadable.sort()
if unreadable:
    warnings.append(cs.cs_warning("CS_W_MEDIA_SKIPPED", count=len(unreadable), total=len(df) - n_no_path, file=paths[unreadable[0]]))

# %% Artifacts: one row per file (row-aligned with the input) and one row per timed segment
out = csml.out_dir("target/academy-parity/run-98732/audio.transcribe/defaults_tiny/out-python")
pd.DataFrame({"row": np.array([f["row"] for f in files], dtype=np.int64), "text": [f["text"] for f in files],
              "language": [f["language"] for f in files]}).to_parquet(os.path.join(out, "transcripts.parquet"), index=False)
seg_df = pd.DataFrame(segs, columns=["media_id", "path", "row", "segment", "start", "end", "text", "avg_logprob", "no_speech_prob", "language"])
seg_df["row"] = seg_df["row"].astype(np.int64)
seg_df["segment"] = seg_df["segment"].astype(np.int64)
seg_df.to_parquet(os.path.join(out, "segments.parquet"), index=False)

# %% Result
langs = Counter(f["language"] for f in files)
top_language = sorted(langs.items(), key=lambda kv: (-kv[1], kv[0]))[0][0]
lp = [s["avg_logprob"] for s in segs]
values = {
    "n_rows": len(df),
    "n_files": len(df) - n_no_path,
    "n_transcribed": len(files),
    "n_unreadable": len(unreadable),
    "n_no_path": n_no_path,
    "audio_seconds": float(sum(f["duration_s"] for f in files)),
    "speech_seconds": float(sum(s["end"] - s["start"] for s in segs)),
    "n_segments": len(segs),
    "n_windows": sum(f["windows"] for f in files),
    "n_skipped_windows": sum(f["skipped"] for f in files),
    "n_tokens": sum(len(t) for t in token_lists),
    "n_words": sum(len(f["text"].split()) for f in files),
    "token_check": wh.token_check(token_lists),
    "mean_avg_logprob": float(np.mean(lp)) if lp else None,
    "mean_no_speech_prob": float(np.mean([s["no_speech_prob"] for s in segs])) if segs else None,
    "n_low_confidence": sum(v < LOGPROB for v in lp),
    "language": top_language,
    "n_languages": len(langs),
    "model": MODEL,
    "task": TASK,
}
for code in sorted(langs):
    values[f"language[{code}]"] = langs[code]
for k, f in enumerate(files[:20], start=1):
    values[f"text[{k}]"] = f["text"]
    if f["language_prob"] is not None:
        values[f"language_prob[{k}]"] = f["language_prob"]
tables = [
    {"key": "transcripts", "title": "Transcripts", "columns": [
        {"key": "file", "label": "File", "type": "string"}, {"key": "language", "label": "Language", "type": "string"},
        {"key": "duration", "label": "Length (s)", "type": "number"}, {"key": "segments", "label": "Segments", "type": "integer"},
        {"key": "text", "label": "Transcript", "type": "string"}],
     "rows": [{"file": os.path.basename(f["path"]), "language": f["language"], "duration": f["duration_s"], "segments": f["segments"],
               "text": f["text"] if len(f["text"]) <= 600 else f["text"][:600] + " …"} for f in files]},
    {"key": "segments", "title": f"Segments{' (first 500)' if len(segs) > 500 else ''}", "columns": [
        {"key": "file", "label": "File", "type": "string"}, {"key": "start", "label": "Start (s)", "type": "number"}, {"key": "end", "label": "End (s)", "type": "number"},
        {"key": "text", "label": "Text", "type": "string"}, {"key": "avg_logprob", "label": "Avg log-probability", "type": "number"},
        {"key": "no_speech_prob", "label": "No-speech probability", "type": "number"}],
     "rows": [{"file": os.path.basename(s["path"]), "start": s["start"], "end": s["end"], "text": s["text"], "avg_logprob": s["avg_logprob"],
               "no_speech_prob": s["no_speech_prob"]} for s in segs[:500]]},
]
charts = []
if segs:
    lane_rows = [f["row"] for f in files[:30]]  # one lane per file, at most 30
    lanes = list(dict.fromkeys(os.path.basename(f["path"]) for f in files[:30]))
    shown = [s for s in segs if s["row"] in lane_rows]
    charts.append(cs.chart("timeline", "segment-timeline", "Segments over time", {
        "start": cs.col("Start (s)", [s["start"] for s in shown], "numeric"),
        "end": cs.col("End (s)", [s["end"] for s in shown], "numeric"),
        "lane": cs.col("File", [os.path.basename(s["path"]) for s in shown], "categorical", lanes),
        "label": cs.col("Text", [s["text"] for s in shown], "categorical"),
        "value": cs.col("Average log-probability", [s["avg_logprob"] for s in shown], "numeric"),
    }, controls={"labels": True, "overlap": False}))
if lp:
    charts.append(cs.chart("confidence", "histogram", "Average log-probability of each segment", {
        "x": cs.col("Average log-probability per token", lp, "numeric")}, controls={"scale": "count", "kde": False}))
assumptions = [
    {"key": "hallucination", "label": "Text can be invented", "status": "warn" if values["n_low_confidence"] else "info",
     "message": (f"{values['n_low_confidence']} of {len(segs)} segments have an average log-probability below {LOGPROB:g}: listen to them before relying on the text."
                 if values["n_low_confidence"] else "No segment falls below the log-probability cutoff; Whisper can still mishear names and numbers.")},
    {"key": "language_detection", "label": "Language from the first 30 seconds", "status": "info",
     "message": (f"Set to {LANGUAGE} for every file." if LANGUAGE else f"Detected per file: {', '.join(f'{c} ({n})' for c, n in sorted(langs.items(), key=lambda kv: (-kv[1], kv[0])))}.")},
    {"key": "greedy_decoding", "label": "One pass, no retries", "status": "info",
     "message": f"{values['n_windows']} windows decoded once each; {values['n_skipped_windows']} skipped as silence."},
    {"key": "speech_privacy", "label": "Recordings of people", "status": "info",
     "message": "Transcripts stay on this computer. Get consent before transcribing other people's recordings."},
] + cs_profile.warning_rows()
cs.publish({
    "title": "Speech to text (Whisper)",
    "engine": cs.engine_info("torch", "safetensors", "numpy", "pandas"),
    "n": len(files),
    "summary": f"{len(files)} files ({values['audio_seconds']:.1f} s) → {len(segs)} segments, {values['n_words']} words; most common language {top_language}.",
    "statistics": [
        {"key": "n_transcribed", "label": "Files transcribed", "value": len(files)},
        {"key": "n_segments", "label": "Segments", "value": len(segs)},
        {"key": "n_words", "label": "Words", "value": values["n_words"]},
        {"key": "mean_avg_logprob", "label": "Mean log-probability", "value": values["mean_avg_logprob"]},
    ],
    "tables": tables,
    "assumptions": assumptions,
    "charts": charts,
    "values": values,
    "warnings": warnings,
    "artifacts": [{"key": "transcripts", "path": os.path.join(out, "transcripts.parquet"), "format": "parquet"},
                  {"key": "segments", "path": os.path.join(out, "segments.parquet"), "format": "parquet"}],
})

CodeSplash writes Whisper out in Python and R from the official weights, and both give the same tokens. The tiny model turned 4 files into 4 timed segments. Read the synthetic vowel's transcript in the result: a sound with no words became a long run of repeated syllables. That is a repetition loop, the decoder feeding on its own output.

04

Invented text

Predict

Predict first

The skip rule is relaxed so a near-silent file is decoded instead of skipped. What does Whisper write?

An empty transcriptA short, fluent phrase that nobody saidAn error message
Reveal

In this run it wrote "Thank you.". Trained on subtitles, the decoder has learned that videos often end with such phrases, and with nothing to hear it writes what is likely. Keep the no-speech skip on, read the no-speech probability and the average log-probability of each segment, and listen to anything low-confidence.

05

Scoring against references

Read
Speech to text (Whisper)Recorded · Python and R agreeRecorded 2026-11-25 · 33 values compared
R

4 files (48.0 s) → 4 segments, 270 words; most common language en.

Files transcribed
4
Segments
4
Words
270
Mean log-probability
−0.4138

Plots

Segments over timeWho or what is active when — and where do they overlap?
View data
End (s)TextFileStart (s)Average log-probability
11And so my fellow Americans ask not what your country can do for you ask what you can do for your country.jfk.wav0−0.1683
2.500ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ahvowels.wav0−0.0599
30And so my fellow Americans ask not what your country can do for you ask what you can do for your country.jfk_long_8k.wav0−0.2339
33God, free.jfk_long_8k.wav30−1.193
Average log-probability of each segmentHow is one numeric variable distributed?
View data
Average log-probability per token
−0.1683
−0.0599
−0.2339
−1.193

Assumptions

  • Text can be invented
  • Language from the first 30 seconds
  • One pass, no retries
  • Recordings of people

Transcripts

FileLanguageLength (s)SegmentsTranscript
jfk.waven111And so my fellow Americans ask not what your country can do for you ask what you can do for your country.
vowels.waven2.5001ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah …
quiet.waven1.5000
jfk_long_8k.waven332And so my fellow Americans ask not what your country can do for you ask what you can do for your country. God, free.

Segments

FileStart (s)End (s)TextAvg log-probabilityNo-speech probability
jfk.wav011And so my fellow Americans ask not what your country can do for you ask what you can do for your country.−0.16830.0692
vowels.wav02.500ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah−0.05990.6014
jfk_long_8k.wav030And so my fellow Americans ask not what your country can do for you ask what you can do for your country.−0.23390.2623
jfk_long_8k.wav3033God, free.−1.1930.2446

Error rates against the references

FileWER (%)CER (%)Reference words
jfk.wav13.6362.77822
jfk_long_8k.wav56.81847.92644
  • 1 rows have no file path and are left out.
  • 1 of 5 files couldn't be decoded, so their rows got missing values (first: aud2_speech/broken.wav).
The exact R script · R R version 4.5.1 (2025-06-13)
# Speech to text (Whisper)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method audio.transcribe 1.1.0 · spec 0ff81111bf1cd49a
# Dataset: aud2_speech (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Audio files listed in the path column
PATH <- "path"
REFERENCE <- "reference"
MODEL <- "tiny"
LANGUAGE <- tolower(trimws("en"))  # empty: detected per file
if (!nzchar(LANGUAGE)) LANGUAGE <- NULL
TASK <- "transcribe"
TIMESTAMPS <- FALSE
CONDITION <- TRUE
NO_SPEECH <- 0.6
LOGPROB <- -1
DATA_DIR <- dirname(normalizePath("tests/parity/fixtures/aud2_speech.parquet", mustWork = FALSE))
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/aud2_speech.parquet", col_select = c(PATH, REFERENCE)))
if (nrow(df) == 0) cs_error("CS_E_NO_ROWS")
if (!is.null(LANGUAGE) && !(LANGUAGE %in% cs_whisper_model_languages(MODEL))) {
  cs_error("CS_E_INVALID_OPTION", option = "language", allowed = "a language code Whisper knows (en, de, es, …) or empty", value = LANGUAGE)
}
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\":null,\"mono\":true,\"offset_seconds\":0,\"sample_rate\":16000}}", simplifyVector = FALSE), "target/academy-parity/run-98732/audio.transcribe/references_english_no_timestamps/out-r", df,
                        "tests/parity/fixtures/aud2_speech.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 <- list()
ids_or_na <- vapply(seq_along(paths), function(i) if (is.na(paths[i]) || is.na(media_ids[i])) NA_character_ else as.character(media_ids[i]), "")
status <- cs_media_status(media, ifelse(is.na(paths), NA_character_, ids_or_na))
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)) {
  i <- unreadable[1]
  cs_error("CS_E_MEDIA_DECODE", file = paths[i], reason = status[i])
}
if (n_no_path > 0) warnings <- c(warnings, sprintf("%d rows have no file path and are left out.", n_no_path))

# %% Whisper (greedy decoding, 30-second windows; ADR 0101)
cs_deep_profile_configure(list(profile = "parity"))
model <- cs_whisper_load(cs_whisper_locate(MODEL))
files <- list(); segs <- list(); token_lists <- list()
first_failure <- NULL
for (k in seq_along(ok)) {
  i <- ok[k]
  # Outside the app the files are decoded here, so a bad file shows up now.
  clip <- tryCatch(cs_media_audio(media, media_ids[i])[[1]], cs_error = function(e) {
    if (!(e$code %in% c("CS_E_MEDIA_DECODE", "CS_E_MEDIA_UNSUPPORTED"))) stop(e)
    e
  })
  if (inherits(clip, "cs_error")) {
    unreadable <- c(unreadable, i)
    if (is.null(first_failure)) first_failure <- clip
    next
  }
  r <- cs_whisper_transcribe(model, clip, LANGUAGE, TASK, TIMESTAMPS, CONDITION, NO_SPEECH, LOGPROB)
  token_lists[[k]] <- r$tokens
  files[[k]] <- list(row = i - 1L, media_id = media_ids[i], path = paths[i], language = r$language, language_prob = r$language_prob,
                     duration_s = r$duration, segments = length(r$segments), text = r$text, windows = r$windows, skipped = r$skipped)
  for (j in seq_along(r$segments)) {
    s <- r$segments[[j]]
    segs[[length(segs) + 1L]] <- list(media_id = media_ids[i], path = paths[i], row = i - 1L, segment = j, start = s$start, end = s$end,
                                      text = s$text, avg_logprob = s$avg_logprob, no_speech_prob = s$no_speech_prob, language = r$language)
  }
}
if (!length(files)) stop(first_failure)
unreadable <- sort(unreadable)
if (length(unreadable)) {
  warnings <- c(warnings, cs_warning("CS_W_MEDIA_SKIPPED", count = length(unreadable), total = nrow(df) - n_no_path,
                                     file = paths[unreadable[1]]))
}
fcol <- function(x, key, type = "") vapply(x, function(e) e[[key]], type)

# %% Artifacts: one row per file (row-aligned with the input) and one row per timed segment
out <- cs_ml_out_dir("target/academy-parity/run-98732/audio.transcribe/references_english_no_timestamps/out-r")
nanoparquet::write_parquet(data.frame(row = as.integer(fcol(files, "row", 1L)), text = fcol(files, "text", ""),
                                      language = fcol(files, "language", ""), stringsAsFactors = FALSE),
                           file.path(out, "transcripts.parquet"))
seg_df <- data.frame(
  media_id = fcol(segs, "media_id", ""), path = fcol(segs, "path", ""), row = as.integer(fcol(segs, "row", 1L)),
  segment = as.integer(fcol(segs, "segment", 1L)), start = fcol(segs, "start", 0), end = fcol(segs, "end", 0),
  text = fcol(segs, "text", ""), avg_logprob = fcol(segs, "avg_logprob", 0), no_speech_prob = fcol(segs, "no_speech_prob", 0),
  language = fcol(segs, "language", ""), stringsAsFactors = FALSE
)
nanoparquet::write_parquet(seg_df, file.path(out, "segments.parquet"))

# %% Result
lang_all <- fcol(files, "language", "")
langs <- table(lang_all)
lang_codes <- names(langs)
lang_n <- as.integer(langs)
ord <- order(-lang_n, lang_codes, method = "radix")
top_language <- lang_codes[ord[1]]
lp <- fcol(segs, "avg_logprob", 0)
texts <- fcol(files, "text", "")
values <- list(
  n_rows = nrow(df),
  n_files = nrow(df) - n_no_path,
  n_transcribed = length(files),
  n_unreadable = length(unreadable),
  n_no_path = n_no_path,
  audio_seconds = sum(fcol(files, "duration_s", 0)),
  speech_seconds = sum(fcol(segs, "end", 0) - fcol(segs, "start", 0)),
  n_segments = length(segs),
  n_windows = sum(fcol(files, "windows", 1L)),
  n_skipped_windows = sum(fcol(files, "skipped", 1L)),
  n_tokens = sum(lengths(token_lists)),
  n_words = sum(cs_whisper_word_count(texts)),
  token_check = cs_whisper_token_check(token_lists),
  mean_avg_logprob = if (length(lp)) mean(lp) else NULL,
  mean_no_speech_prob = if (length(segs)) mean(fcol(segs, "no_speech_prob", 0)) else NULL,
  n_low_confidence = sum(lp < LOGPROB),
  language = top_language,
  n_languages = length(lang_codes),
  model = MODEL,
  task = TASK
)
for (code in sort(lang_codes, method = "radix")) values[[sprintf("language[%s]", code)]] <- as.integer(langs[[code]])
for (k in seq_len(min(20L, length(files)))) {
  values[[sprintf("text[%d]", k)]] <- files[[k]]$text
  if (!is.null(files[[k]]$language_prob)) values[[sprintf("language_prob[%d]", k)]] <- files[[k]]$language_prob
}
short <- function(t) if (nchar(t) <= 600) t else paste0(substr(t, 1, 600), " …")
tables <- list(
  list(key = "transcripts", title = "Transcripts", columns = list(
    list(key = "file", label = "File", type = "string"), list(key = "language", label = "Language", type = "string"),
    list(key = "duration", label = "Length (s)", type = "number"), list(key = "segments", label = "Segments", type = "integer"),
    list(key = "text", label = "Transcript", type = "string")),
    rows = lapply(files, function(f) list(file = basename(f$path), language = f$language, duration = f$duration_s, segments = f$segments,
                                          text = short(f$text)))),
  list(key = "segments", title = if (length(segs) > 500) "Segments (first 500)" else "Segments", columns = list(
    list(key = "file", label = "File", type = "string"), list(key = "start", label = "Start (s)", type = "number"), list(key = "end", label = "End (s)", type = "number"),
    list(key = "text", label = "Text", type = "string"), list(key = "avg_logprob", label = "Avg log-probability", type = "number"),
    list(key = "no_speech_prob", label = "No-speech probability", type = "number")),
    rows = lapply(utils::head(segs, 500), function(s) list(file = basename(s$path), start = s$start, end = s$end, text = s$text,
                                                          avg_logprob = s$avg_logprob, no_speech_prob = s$no_speech_prob)))
)
# %% Word and character error rates against the references (R/text_error_rates.R, as in evaluate.text)
LOWER <- FALSE
refs_all <- as.character(df[[REFERENCE]])
has_ref <- vapply(files, function(f) { x <- refs_all[f$row + 1L]; !is.na(x) && nzchar(trimws(x)) }, TRUE)
scored <- files[has_ref]
values$n_scored <- length(scored)
if (length(scored)) {
  e <- colSums(cs_tm_error_segments(vapply(scored, function(f) f$text, ""), lapply(scored, function(f) refs_all[f$row + 1L]), lowercase = LOWER))
  values["wer"] <- list(cs_tm_error_rate(e[1], e[2])); values["cer"] <- list(cs_tm_error_rate(e[6], e[7]))
  values$wer_sub <- as.integer(e[3]); values$wer_del <- as.integer(e[4]); values$wer_ins <- as.integer(e[5])
  values$wer_ref_words <- as.integer(e[2]); values$cer_ref_chars <- as.integer(e[7])
  rows_er <- lapply(scored, function(f) {
    x <- cs_tm_error_segments(f$text, list(refs_all[f$row + 1L]), lowercase = LOWER)[1, ]
    list(file = basename(f$path), wer = cs_tm_error_rate(x[1], x[2]), cer = cs_tm_error_rate(x[6], x[7]), words = as.integer(x[2]))
  })
  tables[[length(tables) + 1L]] <- list(key = "error_rates", title = "Error rates against the references", columns = list(
    list(key = "file", label = "File", type = "string"), list(key = "wer", label = "WER (%)", type = "number"), list(key = "cer", label = "CER (%)", type = "number"),
    list(key = "words", label = "Reference words", type = "integer")), rows = rows_er)
} else {
  warnings <- c(warnings, "No transcribed file has a reference, so no error rates.")
}
charts <- list()
if (length(segs)) {
  lane_rows <- vapply(utils::head(files, 30), function(f) f$row, 1L)  # one lane per file, at most 30
  lanes <- unique(vapply(utils::head(files, 30), function(f) basename(f$path), ""))
  shown <- Filter(function(s) s$row %in% lane_rows, segs)
  charts[[length(charts) + 1L]] <- cs_chart("timeline", "segment-timeline", "Segments over time", list(
    start = cs_col("Start (s)", vapply(shown, function(s) s$start, 0), "numeric"),
    end = cs_col("End (s)", vapply(shown, function(s) s$end, 0), "numeric"),
    lane = cs_col("File", vapply(shown, function(s) basename(s$path), ""), "categorical", lanes),
    label = cs_col("Text", vapply(shown, function(s) s$text, ""), "categorical"),
    value = cs_col("Average log-probability", vapply(shown, function(s) s$avg_logprob, 0), "numeric")
  ), controls = list(labels = TRUE, overlap = FALSE))
}
if (length(lp)) {
  charts[[length(charts) + 1L]] <- cs_chart("confidence", "histogram", "Average log-probability of each segment",
                          list(x = cs_col("Average log-probability per token", lp, "numeric")), controls = list(scale = "count", kde = FALSE))
}
detected <- paste(sprintf("%s (%d)", lang_codes[ord], lang_n[ord]), collapse = ", ")
assumptions <- c(list(
  list(key = "hallucination", label = "Text can be invented", status = if (values$n_low_confidence > 0) "warn" else "info",
       message = if (values$n_low_confidence > 0) {
         sprintf("%d of %d segments have an average log-probability below %s: listen to them before relying on the text.",
                 values$n_low_confidence, length(segs), format(LOGPROB))
       } else {
         "No segment falls below the log-probability cutoff; Whisper can still mishear names and numbers."
       }),
  list(key = "language_detection", label = "Language from the first 30 seconds", status = "info",
       message = if (!is.null(LANGUAGE)) sprintf("Set to %s for every file.", LANGUAGE) else sprintf("Detected per file: %s.", detected)),
  list(key = "greedy_decoding", label = "One pass, no retries", status = "info",
       message = sprintf("%d windows decoded once each; %d skipped as silence.", values$n_windows, values$n_skipped_windows)),
  list(key = "speech_privacy", label = "Recordings of people", status = "info",
       message = "Transcripts stay on this computer. Get consent before transcribing other people's recordings.")
), cs_deep_profile_warning_rows())
cs_publish(list(
  title = "Speech to text (Whisper)",
  engine = cs_engine_info("torch", "safetensors", "jsonlite", "nanoparquet", "codesplashr"),
  n = length(files),
  summary = sprintf("%d files (%.1f s) → %d segments, %d words; most common language %s.", length(files), values$audio_seconds,
                    length(segs), values$n_words, top_language),
  statistics = list(
    list(key = "n_transcribed", label = "Files transcribed", value = length(files)),
    list(key = "n_segments", label = "Segments", value = length(segs)),
    list(key = "n_words", label = "Words", value = values$n_words),
    list(key = "mean_avg_logprob", label = "Mean log-probability", value = values$mean_avg_logprob)
  ),
  tables = tables,
  assumptions = assumptions,
  charts = charts,
  values = values,
  warnings = warnings,
  artifacts = list(list(key = "transcripts", path = file.path(out, "transcripts.parquet"), format = "parquet"),
                   list(key = "segments", path = file.path(out, "segments.parquet"), format = "parquet"))
))
Python

4 files (48.0 s) → 4 segments, 270 words; most common language en.

Files transcribed
4
Segments
4
Words
270
Mean log-probability
−0.4138

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

Assumptions

  • Text can be invented
  • Language from the first 30 seconds
  • One pass, no retries
  • Recordings of people

Transcripts

FileLanguageLength (s)SegmentsTranscript
jfk.waven111And so my fellow Americans ask not what your country can do for you ask what you can do for your country.
vowels.waven2.5001ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah …
quiet.waven1.5000
jfk_long_8k.waven332And so my fellow Americans ask not what your country can do for you ask what you can do for your country. God, free.

Segments

FileStart (s)End (s)TextAvg log-probabilityNo-speech probability
jfk.wav011And so my fellow Americans ask not what your country can do for you ask what you can do for your country.−0.16830.0692
vowels.wav02.500ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah−0.05990.6014
jfk_long_8k.wav030And so my fellow Americans ask not what your country can do for you ask what you can do for your country.−0.23390.2623
jfk_long_8k.wav3033God, free.−1.1930.2446

Error rates against the references

FileWER (%)CER (%)Reference words
jfk.wav13.6362.77822
jfk_long_8k.wav56.81847.92644
  • 1 rows have no file path and are left out.
  • 1 of 5 files couldn't be decoded, so their rows got missing values (first: aud2_speech/broken.wav).
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Speech to text (Whisper)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method audio.transcribe 1.1.0 · spec 0ff81111bf1cd49a
# Dataset: aud2_speech (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import os
from collections import Counter

import numpy as np
import pandas as pd

import codesplash as cs
from codesplash import ml as csml
from codesplash.audio import whisper as wh
from codesplash.deep import profile as cs_profile

# %% Audio files listed in the path column
PATH = "path"
REFERENCE = "reference"
MODEL = "tiny"
LANGUAGE = "en".strip().lower() or None  # empty: detected per file
TASK = "transcribe"
TIMESTAMPS = False
CONDITION = True
NO_SPEECH = 0.6
LOGPROB = -1
DATA_DIR = os.path.dirname(os.path.abspath("tests/parity/fixtures/aud2_speech.parquet"))
df = pd.read_parquet("tests/parity/fixtures/aud2_speech.parquet", columns=[PATH] if REFERENCE is None else [PATH, REFERENCE])
if not len(df):
    cs.cs_error("CS_E_NO_ROWS")
if LANGUAGE is not None and LANGUAGE not in wh.languages(MODEL):
    cs.cs_error("CS_E_INVALID_OPTION", option="language", allowed="a language code Whisper knows (en, de, es, …) or empty", value=LANGUAGE)
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\":null,\"mono\":true,\"offset_seconds\":0,\"sample_rate\":16000}}"), "target/academy-parity/run-98732/audio.transcribe/references_english_no_timestamps/out-python", df, "tests/parity/fixtures/aud2_speech.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 n_no_path:
    warnings.append(f"{n_no_path} rows have no file path and are left out.")

# %% Whisper (greedy decoding, 30-second windows; ADR 0101)
cs_profile.configure({"profile": "parity"})
model = wh.load(wh.locate(MODEL))
progress = cs.progress(f"Transcribing {len(ok)} files with Whisper {MODEL}", total=len(ok))
files, segs, token_lists = [], [], []
first_failure = None
for k, i in enumerate(ok):
    try:
        clip = cs_media.audio(media, [media_ids[i]])[0]
    except cs.CsError as e:  # outside the app the files are decoded here, so a bad file shows up now
        if e.code not in ("CS_E_MEDIA_DECODE", "CS_E_MEDIA_UNSUPPORTED"):
            raise
        unreadable.append(i)
        first_failure = first_failure or e
        progress.update(k + 1)
        continue
    r = wh.transcribe(model, clip, LANGUAGE, TASK, TIMESTAMPS, CONDITION, NO_SPEECH, LOGPROB)
    token_lists.append(r["tokens"])
    files.append({"row": i, "media_id": media_ids[i], "path": paths[i], "language": r["language"], "language_prob": r["language_prob"],
                  "duration_s": r["duration"], "segments": len(r["segments"]), "text": r["text"], "windows": r["windows"], "skipped": r["skipped"]})
    for j, s in enumerate(r["segments"], start=1):
        segs.append({"media_id": media_ids[i], "path": paths[i], "row": i, "segment": j, "start": s["start"], "end": s["end"], "text": s["text"],
                     "avg_logprob": s["avg_logprob"], "no_speech_prob": s["no_speech_prob"], "language": r["language"]})
    progress.update(k + 1)
progress.done()
if not files:
    raise first_failure
unreadable.sort()
if unreadable:
    warnings.append(cs.cs_warning("CS_W_MEDIA_SKIPPED", count=len(unreadable), total=len(df) - n_no_path, file=paths[unreadable[0]]))

# %% Artifacts: one row per file (row-aligned with the input) and one row per timed segment
out = csml.out_dir("target/academy-parity/run-98732/audio.transcribe/references_english_no_timestamps/out-python")
pd.DataFrame({"row": np.array([f["row"] for f in files], dtype=np.int64), "text": [f["text"] for f in files],
              "language": [f["language"] for f in files]}).to_parquet(os.path.join(out, "transcripts.parquet"), index=False)
seg_df = pd.DataFrame(segs, columns=["media_id", "path", "row", "segment", "start", "end", "text", "avg_logprob", "no_speech_prob", "language"])
seg_df["row"] = seg_df["row"].astype(np.int64)
seg_df["segment"] = seg_df["segment"].astype(np.int64)
seg_df.to_parquet(os.path.join(out, "segments.parquet"), index=False)

# %% Result
langs = Counter(f["language"] for f in files)
top_language = sorted(langs.items(), key=lambda kv: (-kv[1], kv[0]))[0][0]
lp = [s["avg_logprob"] for s in segs]
values = {
    "n_rows": len(df),
    "n_files": len(df) - n_no_path,
    "n_transcribed": len(files),
    "n_unreadable": len(unreadable),
    "n_no_path": n_no_path,
    "audio_seconds": float(sum(f["duration_s"] for f in files)),
    "speech_seconds": float(sum(s["end"] - s["start"] for s in segs)),
    "n_segments": len(segs),
    "n_windows": sum(f["windows"] for f in files),
    "n_skipped_windows": sum(f["skipped"] for f in files),
    "n_tokens": sum(len(t) for t in token_lists),
    "n_words": sum(len(f["text"].split()) for f in files),
    "token_check": wh.token_check(token_lists),
    "mean_avg_logprob": float(np.mean(lp)) if lp else None,
    "mean_no_speech_prob": float(np.mean([s["no_speech_prob"] for s in segs])) if segs else None,
    "n_low_confidence": sum(v < LOGPROB for v in lp),
    "language": top_language,
    "n_languages": len(langs),
    "model": MODEL,
    "task": TASK,
}
for code in sorted(langs):
    values[f"language[{code}]"] = langs[code]
for k, f in enumerate(files[:20], start=1):
    values[f"text[{k}]"] = f["text"]
    if f["language_prob"] is not None:
        values[f"language_prob[{k}]"] = f["language_prob"]
tables = [
    {"key": "transcripts", "title": "Transcripts", "columns": [
        {"key": "file", "label": "File", "type": "string"}, {"key": "language", "label": "Language", "type": "string"},
        {"key": "duration", "label": "Length (s)", "type": "number"}, {"key": "segments", "label": "Segments", "type": "integer"},
        {"key": "text", "label": "Transcript", "type": "string"}],
     "rows": [{"file": os.path.basename(f["path"]), "language": f["language"], "duration": f["duration_s"], "segments": f["segments"],
               "text": f["text"] if len(f["text"]) <= 600 else f["text"][:600] + " …"} for f in files]},
    {"key": "segments", "title": f"Segments{' (first 500)' if len(segs) > 500 else ''}", "columns": [
        {"key": "file", "label": "File", "type": "string"}, {"key": "start", "label": "Start (s)", "type": "number"}, {"key": "end", "label": "End (s)", "type": "number"},
        {"key": "text", "label": "Text", "type": "string"}, {"key": "avg_logprob", "label": "Avg log-probability", "type": "number"},
        {"key": "no_speech_prob", "label": "No-speech probability", "type": "number"}],
     "rows": [{"file": os.path.basename(s["path"]), "start": s["start"], "end": s["end"], "text": s["text"], "avg_logprob": s["avg_logprob"],
               "no_speech_prob": s["no_speech_prob"]} for s in segs[:500]]},
]
# %% Word and character error rates against the references (codesplash.text.error_rates, as in evaluate.text)
from codesplash.text import error_rates as er

LOWER = False
refs_all = df[REFERENCE].tolist()
scored = [f for f in files if refs_all[f["row"]] is not None and not (isinstance(refs_all[f["row"]], float) and refs_all[f["row"]] != refs_all[f["row"]])
          and str(refs_all[f["row"]]).strip()]
values["n_scored"] = len(scored)
if scored:
    e = er.segments([f["text"] for f in scored], [[str(refs_all[f["row"]])] for f in scored], lowercase=LOWER).sum(axis=0)
    values.update({"wer": er.rate(e[0], e[1]), "cer": er.rate(e[5], e[6]), "wer_sub": int(e[2]), "wer_del": int(e[3]), "wer_ins": int(e[4]),
                   "wer_ref_words": int(e[1]), "cer_ref_chars": int(e[6])})
    rows_er = []
    for f in scored:
        x = er.segments([f["text"]], [[str(refs_all[f["row"]])]], lowercase=LOWER)[0]
        rows_er.append({"file": os.path.basename(f["path"]), "wer": er.rate(x[0], x[1]), "cer": er.rate(x[5], x[6]), "words": int(x[1])})
    tables.append({"key": "error_rates", "title": "Error rates against the references", "columns": [
        {"key": "file", "label": "File", "type": "string"}, {"key": "wer", "label": "WER (%)", "type": "number"}, {"key": "cer", "label": "CER (%)", "type": "number"},
        {"key": "words", "label": "Reference words", "type": "integer"}], "rows": rows_er})
else:
    warnings.append("No transcribed file has a reference, so no error rates.")
charts = []
if segs:
    lane_rows = [f["row"] for f in files[:30]]  # one lane per file, at most 30
    lanes = list(dict.fromkeys(os.path.basename(f["path"]) for f in files[:30]))
    shown = [s for s in segs if s["row"] in lane_rows]
    charts.append(cs.chart("timeline", "segment-timeline", "Segments over time", {
        "start": cs.col("Start (s)", [s["start"] for s in shown], "numeric"),
        "end": cs.col("End (s)", [s["end"] for s in shown], "numeric"),
        "lane": cs.col("File", [os.path.basename(s["path"]) for s in shown], "categorical", lanes),
        "label": cs.col("Text", [s["text"] for s in shown], "categorical"),
        "value": cs.col("Average log-probability", [s["avg_logprob"] for s in shown], "numeric"),
    }, controls={"labels": True, "overlap": False}))
if lp:
    charts.append(cs.chart("confidence", "histogram", "Average log-probability of each segment", {
        "x": cs.col("Average log-probability per token", lp, "numeric")}, controls={"scale": "count", "kde": False}))
assumptions = [
    {"key": "hallucination", "label": "Text can be invented", "status": "warn" if values["n_low_confidence"] else "info",
     "message": (f"{values['n_low_confidence']} of {len(segs)} segments have an average log-probability below {LOGPROB:g}: listen to them before relying on the text."
                 if values["n_low_confidence"] else "No segment falls below the log-probability cutoff; Whisper can still mishear names and numbers.")},
    {"key": "language_detection", "label": "Language from the first 30 seconds", "status": "info",
     "message": (f"Set to {LANGUAGE} for every file." if LANGUAGE else f"Detected per file: {', '.join(f'{c} ({n})' for c, n in sorted(langs.items(), key=lambda kv: (-kv[1], kv[0])))}.")},
    {"key": "greedy_decoding", "label": "One pass, no retries", "status": "info",
     "message": f"{values['n_windows']} windows decoded once each; {values['n_skipped_windows']} skipped as silence."},
    {"key": "speech_privacy", "label": "Recordings of people", "status": "info",
     "message": "Transcripts stay on this computer. Get consent before transcribing other people's recordings."},
] + cs_profile.warning_rows()
cs.publish({
    "title": "Speech to text (Whisper)",
    "engine": cs.engine_info("torch", "safetensors", "numpy", "pandas"),
    "n": len(files),
    "summary": f"{len(files)} files ({values['audio_seconds']:.1f} s) → {len(segs)} segments, {values['n_words']} words; most common language {top_language}.",
    "statistics": [
        {"key": "n_transcribed", "label": "Files transcribed", "value": len(files)},
        {"key": "n_segments", "label": "Segments", "value": len(segs)},
        {"key": "n_words", "label": "Words", "value": values["n_words"]},
        {"key": "mean_avg_logprob", "label": "Mean log-probability", "value": values["mean_avg_logprob"]},
    ],
    "tables": tables,
    "assumptions": assumptions,
    "charts": charts,
    "values": values,
    "warnings": warnings,
    "artifacts": [{"key": "transcripts", "path": os.path.join(out, "transcripts.parquet"), "format": "parquet"},
                  {"key": "segments", "path": os.path.join(out, "segments.parquet"), "format": "parquet"}],
})

The word error rateWord error rateSubstitutions + deletions + insertions needed to turn the output into its closest reference, over reference words, in %. aligns the transcript with a reference and counts substitutions, deletions and insertionsSubstitutions, deletions and insertionsWords the output got wrong, left out, or added, in the alignment with the fewest edits.: WER=(S+D+I)/N\mathrm{WER} = (S + D + I)/N, with NN reference words. It can exceed 100%, since insertions are unbounded.

Here the two scored files have 66 reference words, with 8 substitutions and 20 deletions: a WER of 42.4%. Case, punctuation and numerals change it, so publish the normalization with the number.

06

Decoding choices

Explore

DExplorable · Temperature and top-p

What do the sampling settings on a language model actually change?

With these settings, how likely is the single most likely token?

0.50
How sure?
1.00

Below 1 sharpens the distribution; above 1 flattens it.

1.00

Keep the likeliest tokens until they hold this much probability.

12
200

“The p-value tells you how extreme”

surprising0.364unusual0.221likely0.148extreme0.099compatible0.066rare0.045strong0.024much0.016big0.010true0.005purple0.001sandwich0.000
  • With these settings
  • Default (temperature 1, no cut-off)

Twelve sampled tokens: extreme · surprising · surprising · unusual · rare · rare · unusual · surprising · rare · extreme · surprising · likely

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.

Whisper's decoder picks tokens the way any language model does. CodeSplash decodes greedily, always the top token, so Python and R agree exactly. The original package falls back to sampling at a higher temperature when a window looks like a loop; that trades reproducibility for fewer loops. Raise the temperature here and watch how much less predictable the choice becomes.

DExplorable · Decoding: greedy, beam search and sampling

How does the way we pick tokens change the sentence a language model writes?

Method

Greedy takes the likeliest token each step; beam search keeps several partial sentences; sampling draws.

3

Beam search only: partial sentences kept at each step.

Length normalization

Total log-probability always favors shorter sentences; normalizing by length offsets that.

0.60

GNMT only: divide by ((5 + length) / 6)^α.

1.00

Sampling only: below 1 sharpens, above 1 flattens, as in llm-sampling.

10

Sampling only: keep the k likeliest tokens.

1.00

Sampling only: keep the likeliest tokens until they hold this much probability.

8

Tokens before the search stops.

“the data fits well today </s>”

Change the sample to draw another sentence from the same settings.

</s>0.012the0.500a0.400model0.012data0.012noise0.012fits0.012well0.012badly0.012today0.012
Log-probability of the result
−4.239
Tokens
6
Normalized score
−4.239
Gain over greedy (log-probability)
−0.419
  • Puzzle: Find a sentence more likely than greedy's.
  • Puzzle: With beam search, make a sentence of five or more tokens win.
Sampling writes “the data fits well today </s>”: log-probability −4.239 over 6 tokens. Greedy's sentence has log-probability −3.820. The toy model's probabilities are fixed; only the way of choosing changes.

Sampling writes “the data fits well today </s>”: log-probability −4.239 over 6 tokens. Greedy's sentence has log-probability −3.820. The toy model's probabilities are fixed; only the way of choosing changes.

07

SpeechT5: one model, many directions

Read

SpeechT5 shares one encoder–decoder between speech and text. Small modality-specific prenets map speech or text into the shared space, and postnets map the decoder's output back to speech features or text. Pretraining mixes speech reconstruction, text denoising and cross-modal alignment; on the reference's toy numbers two of those terms add up to 0.473.

Fine-tuned copies do recognition, synthesis, voice conversion or enhancement, but each task needs its own trained components, and synthesis also needs a vocoder.

Reference · AUD012 · Explained hereSpeechT5A unified encoder–decoder framework with speech- and text-specific front/back ends. Joint pretraining creates shared representations that can be fine-tuned for recognition, synthesis, translation, conversion, or…
08

SeamlessM4T and MMS

Read

SeamlessM4T translates between speech and text in many languages, including speech to speech: it writes target text, then predicts discrete speech unitsDiscrete speech unitsTokens made by clustering self-supervised speech features. They stand for sounds and let language-model tools generate speech. from it, and a vocoder renders them. On the reference's toy, its text and unit losses sum to 0.919.

Massively Multilingual Speech (MMS) pretrains a wav2vec 2.0-style encoder on audio in over a thousand languages, then adds small per-language adaptersAdapter layersSmall trainable bottleneck layers (down-project, nonlinearity, up-project, add back) inserted into a frozen network. trained with CTC. Language identification and synthesis are separate models. The reference's example weights three languages' losses by sampling shares to 0.68.

Reference · AUD013 · Explained hereSeamlessM4TA multilingual multimodal translation system connecting speech and text, including speech-to-speech pathways. It combines pretrained representations, text translation, and speech-unit generation with supervised and… Reference · AUD014 · Explained hereMassively Multilingual Speech (MMS)A family of massively multilingual speech systems spanning recognition, language identification, and synthesis. Its recognition branch scales self-supervised speech pretraining and supervised language-specific…
09

Where it stands in CodeSplash

Read
EntryIn CodeSplash
Whisper (AUD011)Runs in CodeSplash (Experimental): Speech to text (Whisper), tiny, base and small; Python and R give the same tokens
SpeechT5 (AUD012)Explained here
SeamlessM4T (AUD013)Explained here; its weights are non-commercial, so it can't ship
MMS (AUD014)Explained here; its weights are non-commercial, so it can't ship

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

10

Check: Whisper and multilingual systems

Checkpoint

Check yourself

Why is Whisper's training called weakly supervised?

Show the answer

Answer: b

The labels exist but are noisy: subtitles paraphrase, captions skip words. Scale makes up for much of the noise, not all of it.

Check yourself

How does the same Whisper model switch between transcribing French and translating it to English?

Show the answer

Answer: b

Language, task and timestamp tokens steer one decoder. That's also why a wrong language token can make it translate when you wanted a transcript.

Check yourself

A Whisper transcript of a recording with long music breaks contains a sentence repeated many times. What happened, and what helps?

Show the answer

Answer: b

Repetition loops and invented phrases appear where speech is weak or absent. Confidence values and the no-speech probability point to the segments to check.

Check yourself

A reference has 20 words. The transcript has 2 substitutions, 2 deletions and 1 insertion. What is the WER as a fraction?

Show the answer

Answer: 0.25

(2+2+1)/20=0.25(2 + 2 + 1)/20 = 0.25. Insertions count even though they add words, which is why WER can pass 1.

Check yourself

What lets SpeechT5 share one encoder–decoder between speech and text?

Show the answer

Answer: b

The prenets map speech or text into one hidden space; the postnets map decoder states back out to the needed modality.

Check yourself

You fine-tuned SpeechT5 for text to speech. What else do you need to hear audio?

Show the answer

Answer: b

Its speech postnet predicts acoustic features; a separately trained vocoder renders them as sound.

Check yourself

In SeamlessM4T's speech-to-speech path, what comes between the target text and the output audio?

Show the answer

Answer: b

Units are tokens of sound learned from self-supervised features; a unit vocoder turns them into a waveform.

Check yourself

Why doesn't CodeSplash offer SeamlessM4T or MMS models?

Show the answer

Answer: b

CodeSplash only ships weights whose licenses allow commercial use. Code being public doesn't make the weights usable.

Check yourself

How does MMS cover over a thousand languages for recognition without a full model per language?

Show the answer

Answer: a

The shared weights carry what languages have in common; each adapter adds a little for one language.

11

Recap

Recap
  • Whisper is a weakly supervised encoder–decoder steered by task tokens; it runs in CodeSplash (Experimental).
  • Its failures are invented text and repetition loops where speech is weak; read confidence and listen.
  • WER = (S + D + I)/N, can exceed 100%, and depends on normalization.
  • SpeechT5 shares one model across tasks; SeamlessM4T and MMS go wide on languages, with non-commercial weights.

Concepts in this lesson