ADescribe · audio.transcribe
Speech to text (Whisper)
What is said in these recordings, and when?
Transcribes (or translates to English) the speech in a column of audio files with OpenAI's Whisper, written out in Python and R on torch from the official weights (tiny, base, small, medium, large-v3 or large-v3-turbo; a one-time download you approve). Each file is decoded to 16 kHz mono, cut into 30-second windows and decoded greedily with timestamps; the language is detected per file unless you set it. Results: one transcript per file, a table of timed segments (start, end, text, average log-probability, no-speech probability) you can save as a dataset for text methods, and word and character error rates when a reference column is given. Python and R give the same tokens. Silent windows are skipped, but Whisper can still invent text on music, noise or long pauses: check low-confidence segments.
A real result
Example “Defaults tiny”, recorded in both engines. In the app, “Try this example” loads it into Analyze.
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
View data
| End (s) | Text | File | Start (s) | Average log-probability |
|---|---|---|---|---|
| 11 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. | jfk.wav | 0 | −0.3321 |
| 2.500 | ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah | vowels.wav | 0 | −0.0561 |
| 11 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. | jfk_long_8k.wav | 0 | −0.3195 |
| 32 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. | jfk_long_8k.wav | 11 | −0.1754 |
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
| File | Language | Length (s) | Segments | Transcript |
|---|---|---|---|---|
| jfk.wav | en | 11 | 1 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. |
| vowels.wav | en | 2.500 | 1 | ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah 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.wav | en | 1.500 | 0 | |
| jfk_long_8k.wav | en | 33 | 2 | And 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
| File | Start (s) | End (s) | Text | Avg log-probability | No-speech probability |
|---|---|---|---|---|---|
| jfk.wav | 0 | 11 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. | −0.3321 | 0.0692 |
| vowels.wav | 0 | 2.500 | ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah 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.0561 | 0.6014 |
| jfk_long_8k.wav | 0 | 11 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. | −0.3195 | 0.2623 |
| jfk_long_8k.wav | 11 | 32 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. | −0.1754 | 0.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).
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
| File | Language | Length (s) | Segments | Transcript |
|---|---|---|---|---|
| jfk.wav | en | 11 | 1 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. |
| vowels.wav | en | 2.500 | 1 | ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah 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.wav | en | 1.500 | 0 | |
| jfk_long_8k.wav | en | 33 | 2 | And 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
| File | Start (s) | End (s) | Text | Avg log-probability | No-speech probability |
|---|---|---|---|---|---|
| jfk.wav | 0 | 11 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. | −0.3321 | 0.0692 |
| vowels.wav | 0 | 2.500 | ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah 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.0561 | 0.6014 |
| jfk_long_8k.wav | 0 | 11 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. | −0.3195 | 0.2623 |
| jfk_long_8k.wav | 11 | 32 | And so my fellow Americans ask not what your country can do for you ask what you can do for your country. | −0.1754 | 0.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).
Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.
Worked examples in the app
- Defaults tinyaud2_speech · audio: path
- References english no timestampsaud2_speech · audio: path · reference: reference
- Translate no contextaud2_speech · audio: path · reference: reference
- Base modelaud2_speech · audio: path
- Degenerate all naaud2_speech · audio: path
- Degenerate unknown languageaud2_speech · audio: path
- Degenerate n1aud2_speech · audio: path
- Degenerate n2aud2_speech · audio: path
In the guides
Where it sits in the decision guides
- Multimodal data exploration (text, image, video) · DS & ML Decision Guide · Describe — summarize and visualize
What you need
- Audio file pathcategorical · 1 column
- A column of audio file paths, such as the path column of an audio folder (Data → Add audio folder…). WAV, FLAC, MP3, M4A and OGG are read.
- Reference transcript (optional)categorical · 0–1 column
- What each file really says, when you have it: adds word and character error rates. Empty cells are not scored.
Choices you make
options
- Whisper modeldefault tiny
Larger models make fewer mistakes and take longer. Each is a one-time download that asks first.
- Tiny (39M, 151 MB)(default) — The fastest; good for clear speech and first looks.
- Base (74M, 290 MB) — About twice the time of tiny, with fewer word errors.
- Small (244M, 967 MB) — Clearly more accurate, especially for accents and other languages; several times slower than base.
- Medium (769M, 3.1 GB) — Fewer mistakes than small, mostly in other languages; about three times slower than small. Needs 12 GB of memory.
- Large v3 (1.55B, 3.1 GB) — The most accurate Whisper, and the slowest by far on a CPU. Knows Cantonese too. Needs 24 GB of memory.
- Large v3 turbo (809M, 1.6 GB) — Close to large v3's accuracy with a 4-layer decoder, so it writes text much faster. Knows Cantonese. Needs 12 GB of memory.
- Languagedefault —
A code such as en, de, es or ja (yue, Cantonese, needs large v3 or large v3 turbo). Empty detects the language of each file from its first 30 seconds.
- Taskdefault transcribe
Write down what is said, or translate it into English.
- Transcribe(default) — Text in the language that is spoken.
- Translate to English — English text whatever language is spoken (Whisper's own translation).
- Timestampsdefault on
Splits each 30-second window into timed segments. Off gives one segment per window.
Advanced
- Use previous text as contextdefault on
Each window sees the text before it, which keeps names and style consistent but can repeat a mistake. Turn off if output loops.
- No-speech thresholddefault 0.6
A window is skipped as silence when its no-speech probability is above this and its text is unlikely (log-probability at most the cutoff below).
- Log-probability cutoffdefault -1
Average log-probability per token below which a window counts as unlikely text, for the silence rule and the low-confidence count.
- Compute profiledefault parity
Where and how precisely the model runs. Parity matches the other engine; the faster profiles can give slightly different text.
- Parity(default) — Double precision on one CPU thread: the same tokens in Python and R, run after run (the default).
- Faster CPU — Single precision on all performance cores; repeatable on this Mac, the text can differ slightly from Parity.
- Apple GPU — Single precision on the Apple GPU (macOS 15 or later); the text can differ slightly. Falls back to Faster CPU without a GPU.
statistics
- Ignore case in error ratesdefault on
Lower-case transcripts and references before counting word and character errors. Punctuation still counts.
Checks and remedies
CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.
Text can be invented
On music, noise, long pauses or very quiet speech Whisper can write fluent text nobody said, or repeat a phrase. Check segments with a low log-probability.
Language from the first 30 seconds
With no language set, each file's language is guessed from its first 30 seconds; a file that switches language is transcribed in the first one.
One pass, no retries
Each window is decoded once, always taking the most likely token. OpenAI's retries at higher temperature are random, so they are left out: some windows may loop.
Recordings of people
Voices and what people say are personal data. Transcripts stay on this computer; get consent before transcribing other people's recordings.
What it reports
- n_rows
- Writing down what is said in a recording. The output is text plus, here, timed segments and a confidence per segment.
- n_files
- Writing down what is said in a recording. The output is text plus, here, timed segments and a confidence per segment.
- n_transcribed
- Writing down what is said in a recording. The output is text plus, here, timed segments and a confidence per segment.
- n_unreadable
- Rows with no path, and files that can't be decoded, are left out and counted; the others are still transcribed.
- n_no_path
- Rows with no path, and files that can't be decoded, are left out and counted; the others are still transcribed.
- audio_seconds
- A stretch of speech with a start and end time (in seconds from the file's start) and its text.
- speech_seconds
- A stretch of speech with a start and end time (in seconds from the file's start) and its text.
- n_segments
- A stretch of speech with a start and end time (in seconds from the file's start) and its text.
- n_windows
- Whisper hears 30 s at a time. The next window starts where the last complete segment ended, or after the window.
- n_skipped_windows
- Whisper hears 30 s at a time. The next window starts where the last complete segment ended, or after the window.
- n_tokens
- A checksum of every token id the decoder chose, in order. Equal fingerprints mean Python and R wrote the same tokens.
- n_words
- A checksum of every token id the decoder chose, in order. Equal fingerprints mean Python and R wrote the same tokens.
- token_check
- A checksum of every token id the decoder chose, in order. Equal fingerprints mean Python and R wrote the same tokens.
- mean_avg_logprob
- The mean log-probability Whisper gave its own tokens in a window: near 0 is confident, below −1 is doubtful.
- mean_no_speech_prob
- Whisper's own estimate, at the start of each window, that the window has no speech worth writing down.
- n_low_confidence
- The mean log-probability Whisper gave its own tokens in a window: near 0 is confident, below −1 is doubtful.
- language
- Whisper picks the most likely of its 99 language tokens from the first 30 seconds of each file.
- n_languages
- Whisper picks the most likely of its 99 language tokens from the first 30 seconds of each file.
- model
- OpenAI's speech-recognition model: an audio encoder and a text decoder trained on 680,000 hours of transcribed web audio.
- task
- Writing down what is said in a recording. The output is text plus, here, timed segments and a confidence per segment.
Per group, level or term: language[<code>], text[<file>], language_prob[<file>], n_scored, wer, cer, wer_sub, wer_del, wer_ins, wer_ref_words, cer_ref_chars
Python and R
Python and R agree to 6 decimals (relative tolerance 1e-9). Python uses torch, safetensors, numpy, pandas, codesplash; R uses torch, safetensors, jsonlite, nanoparquet, codesplashr.
Default traps between the two languages
- Both engines run the same written-out model on the same float32 weights (float16 for large-v3 and large-v3-turbo) in float64 (Parity profile, one CPU thread) — codesplash.audio.whisper ↔ codesplashr R/audio_whisper.R — and take the same greedy decisions, so tokens, segment times and texts are identical; log-probabilities differ only by matrix-product rounding between the two LibTorch builds (about 1e-14 relative on the fixtures).
- Hugging Face transformers is the oracle on the same weights and mel features (tests/crosscheck/w8aud2_whisper.py for tiny, base and small; w8gaudx_whisper_large.py for medium, large-v3 and large-v3-turbo) — encoder states, logits, language detection and greedy timestamp decoding.
- The faster compute profiles (single precision, Apple GPU) are labeled and not counted as Python ≡ R (decision 65).
The exact script CodeSplash ran for example “Defaults tiny” · 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"}],
})
The exact script CodeSplash ran for example “Defaults tiny” · 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"))
))
Sources
- Radford A, Kim JW, Xu T, Brockman G, McLeavey C, Sutskever I (2023). Robust speech recognition via large-scale weak supervision. ICML 2023, PMLR 202:28492–28518.
- OpenAI (2022). Whisper: model card and reference implementation (github.com/openai/whisper), MIT license; weights openai/whisper-tiny, -base, -small on Hugging Face, Apache-2.0.
- Vaswani A, Shazeer N, Parmar N, et al. (2017). Attention is all you need. NeurIPS 2017, 5998–6008.
- Sennrich R, Haddow B, Birch A (2016). Neural machine translation of rare words with subword units. ACL 2016, 1715–1725.
- Radford A, Wu J, Child R, Luan D, Amodei D, Sutskever I (2019). Language models are unsupervised multitask learners (GPT-2 byte-level BPE). OpenAI technical report.
- NIST (2009). Speech recognition scoring toolkit (SCTK), sclite: word error rate as substitutions, deletions and insertions over reference words.
From the CodeSplash method registry · audio.transcribe v1.1.0.