vocal-affect-bench / scripts /analyze.cjs
luc-debaupte's picture
Init Commit
f5b6936
Raw
History Blame Contribute Delete
63.6 kB
#!/usr/bin/env node
'use strict'
const fs = require('node:fs')
const path = require('node:path')
const DEFAULT_INPUT = 'public/data/predictions.csv' // balanced 39×7=273 clip set
const DEFAULT_OUTPUT = 'data/results/track1-analysis-combined.html'
// Models to exclude from all reports (kept in raw CSV but not shown)
const EXCLUDED_MODELS = new Set(['gemini_audio'])
// ── Model metadata ──────────────────────────────────────────────────────────
const MODEL_META = {
gemini_audio: {
displayName: 'Google Gemini 2.5 Flash',
shortName: 'Gemini 2.5',
providerShort: 'gemini-2.5-flash',
cssVar: '--m-gemini',
color: '#1d5fa3',
},
gemini_3_5_flash: {
displayName: 'Google Gemini 3.5 Flash',
shortName: 'Gemini 3.5',
providerShort: 'gemini-3.5-flash',
cssVar: '--m-gemini35',
color: '#0b9fd8',
},
hume_prosody: {
displayName: 'Hume AI Prosody',
shortName: 'Hume Prosody',
providerShort: 'speech_prosody',
cssVar: '--m-hume',
color: '#2c7a4e',
},
inworld_voice_profile: {
displayName: 'Inworld Voice Profile',
shortName: 'Inworld Voice',
providerShort: 'inworld-stt-1',
cssVar: '--m-inworld',
color: '#c2541a',
},
openai_realtime: {
displayName: 'OpenAI Realtime',
shortName: 'OpenAI RT',
providerShort: 'gpt-realtime-2',
cssVar: '--m-openai',
color: '#5d4a9a',
},
tr_mimo_v2_5: {
displayName: 'Xiaomi MiMo v2.5',
shortName: 'MiMo v2.5',
providerShort: 'xiaomi/mimo-v2.5',
cssVar: '--m-mimo',
color: '#b5860d',
},
tr_nemotron_omni: {
displayName: 'NVIDIA Nemotron Omni',
shortName: 'Nemotron',
providerShort: 'nvidia/nemotron-omni',
cssVar: '--m-nemotron',
color: '#1a7a6e',
},
tr_voxtral_small: {
displayName: 'Mistral Voxtral Small',
shortName: 'Voxtral',
providerShort: 'mistralai/voxtral-small',
cssVar: '--m-voxtral',
color: '#8b2252',
},
tr_qwen3_5_omni_plus: {
displayName: 'Alibaba Qwen3.5 Omni+',
shortName: 'Qwen3.5',
providerShort: 'qwen3.5-omni-plus',
cssVar: '--m-qwen',
color: '#6b47b8',
},
tr_minimax_m3: {
displayName: 'MiniMax M3',
shortName: 'MiniMax',
providerShort: 'MiniMax-M3',
cssVar: '--m-minimax',
color: '#e05a1e',
},
}
function getModelMeta(modelKey) {
return (
MODEL_META[modelKey] || {
displayName: modelKey,
shortName: modelKey,
providerShort: modelKey,
cssVar: '--m-unknown',
color: '#888888',
}
)
}
// ── Emotion metadata ────────────────────────────────────────────────────────
const EMO_COLORS = {
angry: '#b83320',
disgusted: '#7a3d7a',
fearful: '#2d4e85',
happy: '#9e7515',
neutral: '#5a6368',
sad: '#2361a0',
surprised: '#a05c10',
}
const VALENCE_MAP = {
angry: 'negative',
disgusted: 'negative',
fearful: 'negative',
sad: 'negative',
happy: 'positive',
neutral: 'neutral',
// surprised: excluded from valence
}
// ── CSV parser ──────────────────────────────────────────────────────────────
function parseCsv(text) {
const rows = []
let row = []
let value = ''
let quoted = false
for (let i = 0; i < text.length; i++) {
const char = text[i]
const next = text[i + 1]
if (quoted) {
if (char === '"' && next === '"') {
value += '"'
i++
} else if (char === '"') {
quoted = false
} else {
value += char
}
continue
}
if (char === '"') {
quoted = true
} else if (char === ',') {
row.push(value)
value = ''
} else if (char === '\n') {
row.push(value)
rows.push(row)
row = []
value = ''
} else if (char !== '\r') {
value += char
}
}
if (value || row.length > 0) {
row.push(value)
rows.push(row)
}
const [headers, ...dataRows] = rows.filter((r) => r.some((c) => c !== ''))
if (!headers) return []
return dataRows.map((r) => Object.fromEntries(headers.map((h, i) => [h, r[i] || ''])))
}
// ── Helpers ─────────────────────────────────────────────────────────────────
function pct(num, den) {
if (!den) return 0
return (num / den) * 100
}
function fmtPct(num, den) {
if (!den) return 'n/a'
return `${pct(num, den).toFixed(1)}%`
}
function unique(arr) {
return [...new Set(arr)].sort()
}
function deduplicateRows(rows) {
// Keep last occurrence of each (model_name, audio_id) pair — re-runs overwrite earlier results
const seen = new Map()
for (const row of rows) {
const key = `${row.model_name}|${row.audio_id}`
seen.set(key, row)
}
return [...seen.values()]
}
function groupBy(rows, keyFn) {
const map = new Map()
for (const row of rows) {
const key = keyFn(row)
if (!map.has(key)) map.set(key, [])
map.get(key).push(row)
}
return map
}
function escHtml(str) {
return String(str ?? '')
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
}
// ── Analytics ────────────────────────────────────────────────────────────────
function analyze(rawRows) {
const rows = deduplicateRows(rawRows).filter((r) => !EXCLUDED_MODELS.has(r.model_name))
const audioIds = unique(rows.map((r) => r.audio_id).filter(Boolean))
const modelKeys = unique(rows.map((r) => r.model_name).filter(Boolean))
const emotions = unique(rows.map((r) => r.required_emotion).filter(Boolean))
const scored = rows.filter((r) => !r.error && r.mapped_label)
const correct = scored.filter((r) => r.correct === 'true')
const errors = rows.filter((r) => r.error)
// Per-model summaries
const modelSummaries = modelKeys.map((key) => {
const mRows = rows.filter((r) => r.model_name === key)
const mScored = mRows.filter((r) => !r.error && r.mapped_label)
const mCorrect = mScored.filter((r) => r.correct === 'true')
const mErrors = mRows.filter((r) => r.error)
const meta = getModelMeta(key)
// Per-emotion for this model
const perEmotion = emotions.map((emo) => {
const eRows = mScored.filter((r) => r.required_emotion === emo)
const eCorrect = eRows.filter((r) => r.correct === 'true')
return {
emotion: emo,
rows: eRows.length,
correct: eCorrect.length,
accuracy: pct(eCorrect.length, eRows.length),
accuracyStr: fmtPct(eCorrect.length, eRows.length),
}
}).filter((e) => e.rows > 0)
// Confusion analysis for bias section
const wrongPredictions = mScored.filter((r) => r.correct !== 'true')
// Count predicted labels on wrong rows
const predictedCounts = {}
for (const row of wrongPredictions) {
const lbl = row.mapped_label || row.predicted_label
predictedCounts[lbl] = (predictedCounts[lbl] || 0) + 1
}
const topOverpredicted = Object.entries(predictedCounts)
.sort((a, b) => b[1] - a[1])
.slice(0, 1)
.map(([lbl, cnt]) => ({ label: lbl, count: cnt }))[0] || null
// Top confusion pairs (required → predicted) for wrong rows
const pairCounts = {}
for (const row of wrongPredictions) {
const pred = row.mapped_label || row.predicted_label
const key2 = `${row.required_emotion}${pred}`
pairCounts[key2] = (pairCounts[key2] || 0) + 1
}
const topConfusions = Object.entries(pairCounts)
.sort((a, b) => b[1] - a[1])
.slice(0, 3)
.map(([pair, cnt]) => {
const [from, to] = pair.split('→')
return { from, to, count: cnt }
})
// Most underpredicted (lowest accuracy non-zero-sample emotion)
const sortedByAccuracy = [...perEmotion].sort((a, b) => a.accuracy - b.accuracy)
const worstEmotion = sortedByAccuracy[0] || null
const bestEmotion = [...perEmotion].sort((a, b) => b.accuracy - a.accuracy)[0] || null
return {
key,
meta,
rows: mRows.length,
scored: mScored.length,
correct: mCorrect.length,
errors: mErrors.length,
accuracy: pct(mCorrect.length, mScored.length),
accuracyStr: fmtPct(mCorrect.length, mScored.length),
perEmotion,
topOverpredicted,
topConfusions,
worstEmotion,
bestEmotion,
}
}).sort((a, b) => b.accuracy - a.accuracy || a.key.localeCompare(b.key))
// Overall per-emotion
const overallEmotions = emotions.map((emo) => {
const eRows = scored.filter((r) => r.required_emotion === emo)
const eCorrect = eRows.filter((r) => r.correct === 'true')
return {
emotion: emo,
rows: eRows.length,
correct: eCorrect.length,
accuracy: pct(eCorrect.length, eRows.length),
accuracyStr: fmtPct(eCorrect.length, eRows.length),
}
}).sort((a, b) => a.accuracy - b.accuracy)
// Valence analysis
const valenceRows = scored.filter((r) => VALENCE_MAP[r.required_emotion] !== undefined)
const valenceCategories = ['negative', 'neutral', 'positive']
function valenceOf(emotion) {
return VALENCE_MAP[emotion] || null
}
function predictedValence(mappedLabel) {
return VALENCE_MAP[mappedLabel] || null
}
// Overall valence accuracy by category
const valenceByCategory = valenceCategories.map((cat) => {
const catRows = valenceRows.filter((r) => valenceOf(r.required_emotion) === cat)
const catCorrect = catRows.filter((r) => predictedValence(r.mapped_label) === cat)
return { cat, rows: catRows.length, correct: catCorrect.length, accuracy: pct(catCorrect.length, catRows.length), accuracyStr: fmtPct(catCorrect.length, catRows.length) }
})
// Overall valence confusion matrix
const valenceMatrix = {}
for (const actual of valenceCategories) {
valenceMatrix[actual] = {}
for (const pred of valenceCategories) {
valenceMatrix[actual][pred] = 0
}
}
for (const row of valenceRows) {
const actual = valenceOf(row.required_emotion)
const pred = predictedValence(row.mapped_label)
if (actual && pred) valenceMatrix[actual][pred]++
}
// Per-model valence
const modelValence = modelSummaries.map((ms) => {
const mValRows = valenceRows.filter((r) => r.model_name === ms.key)
const mValCorrect = mValRows.filter((r) => predictedValence(r.mapped_label) === valenceOf(r.required_emotion))
const audioCount = unique(mValRows.map((r) => r.audio_id)).length
// Per-model valence confusion matrix
const mat = {}
for (const actual of valenceCategories) {
mat[actual] = {}
for (const pred of valenceCategories) {
mat[actual][pred] = 0
}
}
for (const row of mValRows) {
const actual = valenceOf(row.required_emotion)
const pred = predictedValence(row.mapped_label)
if (actual && pred) mat[actual][pred]++
}
// Per-category accuracy for per-model valence subtitle
const catAccuracy = {}
for (const cat of valenceCategories) {
const catRows = mValRows.filter((r) => valenceOf(r.required_emotion) === cat)
catAccuracy[cat] = pct(mat[cat][cat], catRows.length)
}
return {
key: ms.key,
meta: ms.meta,
rows: mValRows.length,
audioCount,
correct: mValCorrect.length,
accuracy: pct(mValCorrect.length, mValRows.length),
accuracyStr: fmtPct(mValCorrect.length, mValRows.length),
matrix: mat,
catAccuracy,
}
}).sort((a, b) => b.accuracy - a.accuracy)
const valenceAudioCount = unique(valenceRows.map((r) => r.audio_id)).length
return {
totalRows: rows.length,
audioCount: audioIds.length,
modelCount: modelKeys.length,
emotions,
scored: scored.length,
correct: correct.length,
errors: errors.length,
overallAccuracy: pct(correct.length, scored.length),
overallAccuracyStr: fmtPct(correct.length, scored.length),
modelSummaries,
overallEmotions,
valenceByCategory,
valenceMatrix,
modelValence,
valenceRows: valenceRows.length,
valenceAudioCount,
}
}
// ── HTML generators ──────────────────────────────────────────────────────────
function modelCssVars(modelSummaries) {
return modelSummaries.map((ms) => ` ${ms.meta.cssVar}: ${ms.meta.color};`).join('\n')
}
function emoSwatch(emotion, extra = '') {
const color = EMO_COLORS[emotion] || '#888'
return `<span class="emo-swatch" style="background:${color}${extra ? ';' + extra : ''}"></span>`
}
function modelDot(meta, size = 9) {
return `<span class="model-dot" style="background:${meta.color};width:${size}px;height:${size}px;border-radius:50%;display:inline-block;margin-right:0.5rem"></span>`
}
function accColorClass(accuracy) {
if (accuracy >= 60) return 'acc-great'
if (accuracy >= 40) return 'acc-good'
if (accuracy >= 25) return 'acc-mid'
return 'acc-poor'
}
function leaderboardTable(modelSummaries) {
const rows = modelSummaries.map((ms, i) => {
const rankClass = i === 0 ? 'first' : i === 1 ? 'second' : i === 2 ? 'third' : ''
const medal = i === 0 ? ' 🥇' : i === 1 ? ' 🥈' : i === 2 ? ' 🥉' : ''
return ` <tr>
<td><span class="rank-num ${rankClass}">${i + 1}</span></td>
<td>
<span class="model-dot" style="background:${ms.meta.color}"></span>
<span class="model-name">${escHtml(ms.meta.displayName)}</span>
</td>
<td><span class="pill-small">${escHtml(ms.meta.providerShort)}</span></td>
<td style="font-variant-numeric:tabular-nums">${ms.correct.toLocaleString()} / ${ms.scored.toLocaleString()}</td>
<td>
<span class="pct-display ${accColorClass(ms.accuracy)}">${ms.accuracyStr}</span>
<span class="acc-track"><span class="acc-fill" style="width:${ms.accuracy.toFixed(1)}%;background:${ms.meta.color}"></span></span>
</td>
</tr>`
})
return rows.join('\n')
}
function emotionTableRows(overallEmotions) {
return overallEmotions.map((e) => {
const color = EMO_COLORS[e.emotion] || '#888'
return ` <tr>
<td><span class="emo-name"><span class="emo-swatch" style="background:${color}"></span>${escHtml(e.emotion)}</span></td>
<td>${e.rows.toLocaleString()}</td><td>${e.correct.toLocaleString()}</td>
<td><span class="acc-pct" style="color:${color}">${e.accuracyStr}</span></td>
</tr>`
}).join('\n')
}
function biasGrid(modelSummaries) {
const cols = modelSummaries.map((ms) => {
const topOver = ms.topOverpredicted
const topConfusions = ms.topConfusions.slice(0, 3)
const worst = ms.worstEmotion
const best = ms.bestEmotion
const confusionHtml = topConfusions.map((c) => {
const toColor = EMO_COLORS[c.to] || '#888'
return ` <div class="bias-pair"><span class="from">${escHtml(c.from)}</span><span class="arrow">→</span><span class="to" style="color:${toColor}">${escHtml(c.to)}</span><span class="count">${c.count}×</span></div>`
}).join('\n')
return ` <div class="bias-col">
<div class="bias-model-name" style="color:${ms.meta.color}">${escHtml(ms.meta.displayName)}</div>
<div class="bias-model-sub">${escHtml(ms.meta.providerShort)} &nbsp;·&nbsp; overall ${ms.accuracyStr}</div>
<div class="bias-inner">
<div class="bias-block">
<div class="bias-label over">Most over-predicted</div>
<div class="bias-emotion">${escHtml(topOver?.label || 'n/a')}</div>
<div class="bias-desc">${topOver ? `${topOver.count} wrong calls to "${escHtml(topOver.label)}"` : '—'}</div>
<div class="bias-confusions">
${confusionHtml}
</div>
</div>
<div class="bias-block">
<div class="bias-label under">Weakest emotion</div>
<div class="bias-emotion">${escHtml(worst?.emotion || 'n/a')}</div>
<div class="bias-desc">${worst ? `${worst.accuracyStr} (${worst.correct}/${worst.rows})` : '—'}</div>
</div>
<div class="bias-block">
<div class="bias-label note">Strongest emotion</div>
<div class="bias-emotion">${escHtml(best?.emotion || 'n/a')}</div>
<div class="bias-desc">${best ? best.accuracyStr : '—'}</div>
</div>
</div>
</div>`
})
return cols.join('\n\n')
}
function modelDetailGrid(modelSummaries) {
return modelSummaries.map((ms) => {
const sorted = ms.perEmotion.slice().sort((a, b) => b.accuracy - a.accuracy)
const bars = sorted.map((e) => {
const color = EMO_COLORS[e.emotion] || '#888'
const w = e.accuracy.toFixed(1)
return ` <div class="emo-bar-row">
<span class="emo-bar-label">${escHtml(e.emotion)}</span>
<div class="emo-bar-track"><div class="emo-bar-fill" style="width:${w}%;background:${color}"></div></div>
<span class="emo-bar-val" style="color:${color}">${e.accuracyStr}</span>
</div>`
}).join('\n')
return ` <div class="model-card">
<div class="model-card-header">
<div>${modelDot(ms.meta, 10)}<span class="model-block-name">${escHtml(ms.meta.displayName)}</span></div>
<span class="model-card-pct ${accColorClass(ms.accuracy)}">${ms.accuracyStr}</span>
</div>
<div class="model-block-subtitle">${escHtml(ms.meta.providerShort)} · ${ms.correct} / ${ms.scored}</div>
<div class="emo-bar-list">
${bars}
</div>
</div>`
}).join('\n\n')
}
function valenceLeaderboard(modelValence) {
return modelValence.map((mv, i) => {
const rankClass = i === 0 ? 'first' : i === 1 ? 'second' : ''
return ` <tr>
<td><span class="rank-num ${rankClass}">${i + 1}</span></td>
<td><span class="model-dot" style="background:${mv.meta.color}"></span><span class="model-name">${escHtml(mv.meta.displayName)}</span></td>
<td><span class="pill-small">${escHtml(mv.meta.providerShort)}</span></td>
<td>${mv.correct.toLocaleString()} / ${mv.audioCount.toLocaleString()}</td>
<td><span class="acc-pct" style="color:${mv.meta.color}">${mv.accuracyStr}</span></td>
</tr>`
}).join('\n')
}
function valenceMatrixHtml(mat) {
const cats = ['negative', 'neutral', 'positive']
return cats.map((actual) => {
const total = cats.reduce((sum, pred) => sum + mat[actual][pred], 0)
const cells = cats.map((pred) => `<td>${mat[actual][pred].toLocaleString()}</td>`).join('')
return ` <tr><td><strong>${actual}</strong></td>${cells}<td>${total.toLocaleString()}</td></tr>`
}).join('\n')
}
function perModelValenceGrid(modelValence) {
const cats = ['negative', 'neutral', 'positive']
return modelValence.map((mv) => {
const rows = cats.map((actual) => {
const total = cats.reduce((sum, pred) => sum + mv.matrix[actual][pred], 0)
const acc = mv.catAccuracy[actual]
const cells = cats.map((pred) => `<td>${mv.matrix[actual][pred]}</td>`).join('')
return ` <tr><td><strong>${actual}</strong> <span style="color:var(--muted)">(${acc.toFixed(1)}%)</span></td>${cells}<td>${total}</td></tr>`
}).join('\n')
return ` <div class="model-block">
<div class="model-block-header">
<div>${modelDot(mv.meta, 10)}<span class="model-block-name">${escHtml(mv.meta.displayName)}</span></div>
<span class="model-block-pct" style="color:${mv.meta.color}">${mv.accuracyStr}</span>
</div>
<div class="model-block-subtitle">${escHtml(mv.meta.providerShort)} · ${mv.correct} / ${mv.audioCount}</div>
<table class="emotion-table" style="margin-top:0.75rem;font-size:12px">
<thead><tr><th>Actual \\ Predicted</th><th>Negative</th><th>Neutral</th><th>Positive</th><th>Total</th></tr></thead>
<tbody>
${rows}
</tbody>
</table>
</div>`
}).join('\n\n')
}
// ── Chart JS data ────────────────────────────────────────────────────────────
function chartScript(analysis) {
const { modelSummaries, overallEmotions } = analysis
const emotions = overallEmotions.map((e) => e.emotion)
const modelNames = modelSummaries.map((ms) => ms.meta.displayName)
const modelColors = modelSummaries.map((ms) => ms.meta.color)
const modelDataObj = Object.fromEntries(
modelSummaries.map((ms) => {
const byEmo = Object.fromEntries(ms.perEmotion.map((e) => [e.emotion, e.accuracy]))
const data = emotions.map((emo) => Number((byEmo[emo] || 0).toFixed(1)))
return [ms.meta.displayName, data]
})
)
const emotionAccuracies = overallEmotions.map((e) => Number(e.accuracy.toFixed(1)))
const emotionColors = overallEmotions.map((e) => EMO_COLORS[e.emotion] || '#888')
const correctCount = analysis.correct
const incorrectCount = analysis.scored - analysis.correct
return `<script>
Chart.defaults.font.family = "'DM Sans', sans-serif";
Chart.defaults.font.size = 12;
Chart.defaults.color = '#7a746c';
Chart.defaults.borderColor = '#dbd5cc';
const BG = '#f5f1eb';
const RULE = '#dbd5cc';
const MODELS = ${JSON.stringify(modelNames)};
const MODEL_COLORS = ${JSON.stringify(modelColors)};
const EMOTIONS = ${JSON.stringify(emotions)};
const EMO_COLORS_ARR = ${JSON.stringify(emotionColors)};
const MODEL_DATA = ${JSON.stringify(modelDataObj, null, 2)};
// 1. Doughnut
new Chart(document.getElementById('pieOverall'), {
type: 'doughnut',
data: {
labels: ['Correct','Incorrect'],
datasets: [{ data: [${correctCount}, ${incorrectCount}], backgroundColor: ['#2c7a4e','#dbd5cc'], borderWidth: 0, hoverOffset: 4 }]
},
options: {
cutout: '72%',
plugins: { legend: { display: false }, tooltip: { callbacks: { label: c => \` \${c.label}: \${c.raw.toLocaleString()}\` }}},
}
});
// 2. Horizontal bar: Emotion difficulty
new Chart(document.getElementById('barEmotions'), {
type: 'bar',
data: {
labels: ${JSON.stringify(overallEmotions.map((e) => e.emotion))},
datasets: [{ data: ${JSON.stringify(emotionAccuracies)}, backgroundColor: ${JSON.stringify(emotionColors)}, borderWidth: 0, borderRadius: 0 }]
},
options: {
indexAxis: 'y',
layout: { padding: { right: 8 } },
scales: {
x: { min: 0, max: 100, ticks: { callback: v => v + '%', stepSize: 20 }, grid: { color: RULE }, border: { display: false } },
y: { grid: { display: false }, border: { display: false } },
},
plugins: { legend: { display: false }, tooltip: { callbacks: { label: c => \` \${c.raw}% accuracy\` }}},
}
});
// 3. Grouped bar: Model × Emotion
new Chart(document.getElementById('barGrouped'), {
type: 'bar',
data: {
labels: EMOTIONS,
datasets: MODELS.map((name, i) => ({
label: name, data: MODEL_DATA[name], backgroundColor: MODEL_COLORS[i], borderWidth: 0, borderRadius: 0,
}))
},
options: {
scales: {
y: { min: 0, max: 100, ticks: { callback: v => v + '%', stepSize: 25 }, grid: { color: RULE }, border: { display: false } },
x: { grid: { display: false }, border: { display: false } },
},
plugins: {
legend: { position: 'bottom', labels: { padding: 18, boxWidth: 10, boxHeight: 10, useBorderRadius: false } },
tooltip: { callbacks: { label: c => \` \${c.dataset.label}: \${c.raw}%\` }},
},
}
});
// 4. Radar
new Chart(document.getElementById('radarAll'), {
type: 'radar',
data: {
labels: EMOTIONS,
datasets: MODELS.map((name, i) => ({
label: name, data: MODEL_DATA[name],
borderColor: MODEL_COLORS[i], backgroundColor: MODEL_COLORS[i] + '18',
pointBackgroundColor: MODEL_COLORS[i], pointRadius: 3, borderWidth: 1.5,
}))
},
options: {
scales: {
r: {
min: 0, max: 100,
ticks: { stepSize: 25, callback: v => v ? v + '%' : '', backdropColor: 'transparent', font: { size: 10 } },
grid: { color: RULE }, angleLines: { color: RULE },
pointLabels: { color: '#7a746c', font: { size: 12 } },
}
},
plugins: { legend: { display: false }, tooltip: { callbacks: { label: c => \` \${c.dataset.label}: \${c.raw}%\` }}},
}
});
</script>`
}
// ── Main HTML builder ────────────────────────────────────────────────────────
function buildHtml(analysis, inputPath) {
const {
totalRows, audioCount, modelCount, scored, correct, errors,
overallAccuracyStr, modelSummaries, overallEmotions,
valenceByCategory, valenceMatrix, modelValence, valenceRows, valenceAudioCount,
} = analysis
const sortedByAcc = [...modelSummaries] // already sorted desc
const best = sortedByAcc[0]
const worst = sortedByAcc[sortedByAcc.length - 1]
const hardestEmo = overallEmotions[0]
const easiestEmo = overallEmotions[overallEmotions.length - 1]
const today = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })
const modelCountStr = `${modelCount} Models Evaluated`
const radarLegend = modelSummaries.map((ms) =>
` <div style="display:flex;align-items:center;gap:0.7rem;font-size:13px"><span style="display:inline-block;width:28px;height:3px;background:${ms.meta.color}"></span> ${escHtml(ms.meta.displayName)}${ms.accuracyStr}</div>`
).join('\n')
const vNegRow = valenceByCategory.find((v) => v.cat === 'negative')
const vPosRow = valenceByCategory.find((v) => v.cat === 'positive')
const vNeuRow = valenceByCategory.find((v) => v.cat === 'neutral')
const valByCatRows = valenceByCategory.map((v) => {
const color = v.cat === 'negative' ? 'var(--red)' : v.cat === 'positive' ? 'var(--emo-happy)' : 'var(--emo-neutral)'
return ` <tr><td>${v.cat}</td><td>${v.rows.toLocaleString()}</td><td>${v.correct.toLocaleString()}</td><td><span class="acc-pct" style="color:${color}">${v.accuracyStr}</span></td></tr>`
}).join('\n')
// CSS vars for models
const modelVars = modelSummaries.map((ms) => ` ${ms.meta.cssVar}: ${ms.meta.color};`).join('\n')
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Speech Emotion Recognition Benchmark — Combined</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300..900;1,9..144,300..900&family=DM+Sans:wght@300;400;500;600&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--bg: #f5f1eb;
--surface: #ede8e0;
--rule: #cdc6bb;
--text: #1c1815;
--muted: #7a746c;
--faint: #a8a098;
--ink: #302a24;
--red: #c2381f;
${modelVars}
--emo-angry: #b83320;
--emo-disgusted: #7a3d7a;
--emo-fearful: #2d4e85;
--emo-happy: #9e7515;
--emo-neutral: #5a6368;
--emo-sad: #2361a0;
--emo-surprised: #a05c10;
}
html { scroll-behavior: smooth; }
body {
background: var(--bg);
color: var(--text);
font-family: 'DM Sans', sans-serif;
font-weight: 400;
font-size: 15px;
line-height: 1.6;
-webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 2rem; }
hr.rule { border: none; border-top: 1px solid var(--rule); margin: 0; }
hr.rule-thick { border: none; border-top: 2px solid var(--text); margin: 0; }
.masthead { padding: 3.5rem 0 0; }
.masthead-inner { display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 1rem; }
.masthead-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--red); margin-bottom: 0.5rem; }
.masthead h1 { font-family: 'Fraunces', serif; font-optical-sizing: auto; font-size: clamp(2.4rem, 5vw, 3.8rem); font-weight: 800; line-height: 1.05; color: var(--ink); letter-spacing: -0.02em; }
.masthead-meta { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.8; }
.lead-section { padding: 3rem 0 2.5rem; display: grid; grid-template-columns: 1fr 1fr; gap: 4rem; align-items: start; }
.lead-statement { font-family: 'Fraunces', serif; font-optical-sizing: auto; font-size: clamp(1.25rem, 2.5vw, 1.7rem); font-weight: 400; font-style: italic; line-height: 1.4; color: var(--ink); }
.lead-statement strong { font-style: normal; font-weight: 700; }
.lead-stats { display: flex; flex-direction: column; gap: 0; padding-top: 0.25rem; }
.stat-row { display: flex; align-items: center; gap: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--rule); }
.stat-row:last-child { border-bottom: none; padding-bottom: 0; }
.stat-num { font-family: 'Fraunces', serif; font-optical-sizing: auto; font-size: 2rem; font-weight: 800; line-height: 1; color: var(--ink); flex-shrink: 0; min-width: 7rem; text-align: right; white-space: nowrap; }
.stat-desc { font-size: 13px; color: var(--muted); line-height: 1.4; }
.stat-desc strong { color: var(--text); font-weight: 500; }
.section-header { display: flex; align-items: center; gap: 1.25rem; padding: 2.5rem 0 1.5rem; }
.section-num { font-family: 'Fraunces', serif; font-size: 0.85rem; font-weight: 800; color: var(--red); }
.section-title { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.leaderboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 3rem; padding-bottom: 2.5rem; align-items: start; }
.leaderboard-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.leaderboard-table thead tr { border-bottom: 2px solid var(--text); }
.leaderboard-table th { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 0 0.75rem 0.6rem 0; text-align: left; white-space: nowrap; }
.leaderboard-table th:last-child { text-align: right; }
.leaderboard-table td { padding: 0.7rem 0.75rem 0.7rem 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.leaderboard-table td:last-child { text-align: right; }
.rank-num { font-family: 'Fraunces', serif; font-weight: 800; font-size: 1rem; color: var(--faint); width: 24px; display: inline-block; }
.rank-num.first { color: var(--ink); }
.rank-num.second { color: var(--muted); }
.rank-num.third { color: var(--muted); }
.model-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 0.4rem; vertical-align: middle; flex-shrink: 0; }
.model-name { font-weight: 500; }
.pct-display { font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.05rem; }
.pct-display.acc-great { color: #1a6b3a; }
.pct-display.acc-good { color: #2d6b1a; }
.pct-display.acc-mid { color: #8a6200; }
.pct-display.acc-poor { color: #9b2a14; }
.acc-track { display: inline-block; width: 130px; height: 5px; background: var(--surface); border-radius: 0; vertical-align: middle; margin-left: 0.6rem; overflow: hidden; }
.acc-fill { display: block; height: 100%; }
.pill-small { font-size: 10px; padding: 0.2em 0.5em; background: var(--surface); color: var(--muted); font-weight: 500; letter-spacing: 0.03em; }
.lb-chart-side { display: flex; flex-direction: column; gap: 1.5rem; }
.lb-chart-side h3 { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding-bottom: 0.75rem; border-bottom: 1px solid var(--rule); }
.donut-wrap { position: relative; width: 180px; height: 180px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-pct { font-family: 'Fraunces', serif; font-weight: 800; font-size: 1.9rem; line-height: 1; color: var(--ink); }
.donut-label { font-size: 10px; color: var(--muted); letter-spacing: 0.07em; text-transform: uppercase; margin-top: 2px; }
.legend-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; font-size: 12.5px; }
.legend-item { display: flex; align-items: center; gap: 0.6rem; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-item .legend-val { margin-left: auto; font-weight: 500; font-size: 12px; color: var(--muted); }
.emotion-section { padding-bottom: 2.5rem; }
.emotion-chart-wrap { height: 280px; margin-bottom: 1.5rem; }
.emotion-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.emotion-table thead tr { border-bottom: 2px solid var(--text); }
.emotion-table th { font-size: 10.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 0 0 0.6rem; text-align: left; }
.emotion-table th:not(:first-child) { text-align: right; }
.emotion-table td { padding: 0.55rem 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.emotion-table td:not(:first-child) { text-align: right; }
.emo-name { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.emo-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; display: inline-block; }
.acc-pct { font-family: 'Fraunces', serif; font-weight: 700; }
.model-section { padding-bottom: 2.5rem; }
.model-chart-wrap { height: 440px; }
.radar-section { padding-bottom: 3rem; display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: start; }
.radar-wrap { height: 400px; }
/* ── Per-model card grid (4-col) ── */
.model-card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin-bottom: 2.5rem; }
.model-card { background: var(--surface); padding: 1.25rem 1.25rem 1.4rem; }
.model-card-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.15rem; padding-bottom: 0.6rem; border-bottom: 2px solid var(--rule); }
.model-card-pct { font-family: 'Fraunces', serif; font-weight: 800; font-size: 1.35rem; }
.model-card-pct.acc-great { color: #1a6b3a; }
.model-card-pct.acc-good { color: #2d6b1a; }
.model-card-pct.acc-mid { color: #8a6200; }
.model-card-pct.acc-poor { color: #9b2a14; }
/* keep .model-block for valence section */
.model-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin-bottom: 2.5rem; }
.model-block { background: var(--surface); padding: 1.75rem; }
.model-block-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 0.25rem; padding-bottom: 0.75rem; border-bottom: 2px solid var(--rule); }
.model-block-name { font-family: 'Fraunces', serif; font-weight: 800; font-size: 1.1rem; color: var(--ink); }
.model-block-pct { font-family: 'Fraunces', serif; font-weight: 800; font-size: 1.5rem; color: var(--ink); }
.model-block-subtitle { font-size: 11px; color: var(--muted); letter-spacing: 0.03em; margin-bottom: 1rem; }
/* ── Mini emotion bars (in cards) ── */
.emo-bar-list { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.75rem; }
.emo-bar-row { display: grid; grid-template-columns: 60px 1fr 44px; align-items: center; gap: 0.5rem; font-size: 11.5px; }
.emo-bar-label { color: var(--muted); text-align: right; font-size: 11px; }
.emo-bar-track { background: var(--bg); height: 6px; position: relative; overflow: hidden; }
.emo-bar-fill { position: absolute; left: 0; top: 0; bottom: 0; }
.emo-bar-val { font-weight: 600; font-size: 11px; text-align: right; }
/* ── Bias grid — 2 col ── */
.bias-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 2px solid var(--text); margin-bottom: 2.5rem; }
.bias-col { padding: 1.5rem 1.75rem 1.75rem; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.bias-col:nth-child(even) { border-right: none; }
.bias-model-name { font-family: 'Fraunces', serif; font-weight: 800; font-size: 1.1rem; margin-bottom: 0.2rem; }
.bias-model-sub { font-size: 10.5px; color: var(--muted); margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rule); }
.bias-inner { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }
.bias-block { }
.bias-label { font-size: 9px; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; margin-bottom: 0.35rem; }
.bias-label.over { color: #9b2a14; }
.bias-label.under { color: #1d4472; }
.bias-label.note { color: var(--muted); }
.bias-emotion { font-family: 'Fraunces', serif; font-weight: 700; font-size: 0.95rem; margin-bottom: 0.2rem; }
.bias-desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.bias-desc strong { color: var(--text); font-weight: 500; }
.bias-confusions { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.25rem; }
.bias-pair { display: flex; align-items: center; gap: 0.4rem; font-size: 11px; color: var(--muted); }
.bias-pair .from { font-weight: 600; color: var(--text); }
.bias-pair .arrow { color: var(--faint); font-size: 10px; }
.bias-pair .to { font-weight: 600; }
.bias-pair .count { margin-left: auto; font-size: 10px; color: var(--faint); }
/* ── TLDR ── */
.tldr-box { background: var(--ink); color: #f5f1eb; padding: 2rem 2.5rem; margin: 2rem 0; }
.tldr-label { font-size: 10px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--red); margin-bottom: 0.75rem; }
.tldr-text { font-family: 'Fraunces', serif; font-size: clamp(1.05rem, 2vw, 1.3rem); font-weight: 400; font-style: italic; line-height: 1.5; }
.tldr-text strong { font-style: normal; font-weight: 700; color: #fff; }
.tldr-bullets { margin-top: 1.25rem; display: flex; flex-direction: column; gap: 0.4rem; }
.tldr-bullet { display: flex; gap: 0.75rem; font-size: 13px; color: #c8c0b5; line-height: 1.5; }
.tldr-bullet::before { content: '—'; color: var(--red); flex-shrink: 0; font-weight: 700; }
.tldr-bullet strong { color: #f5f1eb; font-weight: 500; }
/* ── Blog prose sections ── */
.blog-section { padding: 2.5rem 0 2rem; }
.blog-section + hr.rule { margin-top: 0; }
.blog-h2 { font-family: 'Fraunces', serif; font-size: clamp(1.3rem, 2.5vw, 1.75rem); font-weight: 800; line-height: 1.15; color: var(--ink); margin-bottom: 1rem; letter-spacing: -0.01em; }
.blog-body { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: start; }
.blog-body.single { grid-template-columns: 1fr; max-width: 700px; }
.blog-prose { font-size: 14px; line-height: 1.75; color: var(--muted); }
.blog-prose p { margin-bottom: 1rem; }
.blog-prose p:last-child { margin-bottom: 0; }
.blog-prose strong { color: var(--text); font-weight: 500; }
.blog-prose em { font-style: italic; }
.callout-box { background: var(--surface); padding: 1.5rem 1.75rem; border-left: 3px solid var(--red); }
.callout-label { font-size: 9px; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: var(--red); margin-bottom: 0.6rem; }
.callout-text { font-family: 'Fraunces', serif; font-size: 1.05rem; font-weight: 400; font-style: italic; line-height: 1.5; color: var(--ink); }
.eval-pills { display: flex; flex-direction: column; gap: 1rem; }
.eval-pill { background: var(--surface); padding: 1.25rem 1.5rem; }
.eval-pill-label { font-size: 9px; font-weight: 700; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.35rem; }
.eval-pill-title { font-family: 'Fraunces', serif; font-weight: 800; font-size: 1.05rem; color: var(--ink); margin-bottom: 0.3rem; }
.eval-pill-desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.takeaways-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin-bottom: 2.5rem; }
.takeaway-card { background: var(--surface); padding: 1.5rem 1.75rem; }
.takeaway-num { font-family: 'Fraunces', serif; font-weight: 800; font-size: 2rem; color: var(--rule); line-height: 1; margin-bottom: 0.5rem; }
.takeaway-title { font-weight: 600; font-size: 13.5px; color: var(--ink); margin-bottom: 0.4rem; }
.takeaway-desc { font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.takeaway-desc strong { color: var(--text); font-weight: 500; }
footer { padding: 2rem 0 3rem; display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--faint); }
footer code { font-family: 'DM Mono', 'Fira Code', monospace; font-size: 10.5px; background: var(--surface); padding: 0.15em 0.4em; }
@media (max-width: 960px) {
.model-card-grid { grid-template-columns: 1fr 1fr; }
.bias-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
.lead-section { grid-template-columns: 1fr; gap: 2rem; }
.leaderboard-grid { grid-template-columns: 1fr; gap: 2rem; }
.radar-section { grid-template-columns: 1fr; }
.model-detail-grid { grid-template-columns: 1fr; }
.model-card-grid { grid-template-columns: 1fr; }
.masthead-inner { flex-direction: column; align-items: flex-start; gap: 1rem; }
.masthead-meta { text-align: left; }
.bias-grid { grid-template-columns: 1fr; }
.bias-col { border-right: none; }
.bias-inner { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<!-- ═══════════════════ MASTHEAD ═══════════════════ -->
<div class="wrap">
<div class="masthead">
<div class="masthead-inner">
<div class="masthead-left">
<div class="masthead-eyebrow">2026 · ${modelCount} Models Evaluated — Combined Run</div>
<h1>Speech Emotion<br>Recognition<br>Benchmark</h1>
</div>
<div class="masthead-meta">
Generated ${today}<br>
${audioCount.toLocaleString()} audio files · 7 emotion labels<br>
${modelCount} models evaluated
</div>
</div>
</div>
</div>
<hr class="rule-thick">
<!-- ═══════════════════ TLDR ═══════════════════ -->
<div class="wrap">
<div class="tldr-box">
<div class="tldr-label">TL;DR</div>
<div class="tldr-text">We benchmarked <strong>${modelCount} production speech-emotion AI models</strong> on a balanced set of 273 real human voice recordings across 7 emotions. The best model hit <strong>${best.accuracyStr}</strong> — barely above chance on the hardest emotions.</div>
<div class="tldr-bullets">
<div class="tldr-bullet">No model exceeds <strong>${best.accuracyStr} accuracy</strong> on a balanced 7-class task. Random baseline is 14.3%.</div>
<div class="tldr-bullet"><strong>${easiestEmo.emotion.charAt(0).toUpperCase() + easiestEmo.emotion.slice(1)}</strong> is reliably detected (${easiestEmo.accuracyStr}). <strong>${hardestEmo.emotion.charAt(0).toUpperCase() + hardestEmo.emotion.slice(1)}</strong> is nearly invisible (${hardestEmo.accuracyStr}).</div>
<div class="tldr-bullet">Almost every model is <strong>biased toward predicting "neutral"</strong> — a safe default that inflates overall accuracy but fails in practice.</div>
<div class="tldr-bullet">Standard speech pipelines <strong>transcribe first, then process text</strong> — discarding all prosodic signal. A dedicated SER model must run at the audio stage.</div>
</div>
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ WHY IT MATTERS ═══════════════════ -->
<div class="wrap">
<div class="blog-section">
<div class="blog-h2">Why speech emotion detection matters for AI agents</div>
<div class="blog-body">
<div class="blog-prose">
<p>Most AI voice agents today use a <strong>cascading architecture</strong>: audio is first converted to text by a speech-to-text model, then that transcript is passed to an LLM to generate a response. This pipeline is fast and effective — but it silently discards something critical.</p>
<p>When audio becomes text, <strong>all prosodic information is lost</strong>: tone, pitch, tempo, tremor, and vocal energy that carry emotional meaning are stripped away. The LLM downstream only sees words. A customer saying "I'm fine" in a frustrated, clipped voice looks identical to one saying it calmly.</p>
<p>If you want your agent to respond differently based on how a customer feels — escalating to a human when someone sounds distressed, adjusting tone when frustration is detected, or personalizing a response when someone sounds excited — <strong>you need a dedicated speech emotion recognition model running on the raw audio, before transcription</strong>.</p>
<p>This benchmark exists to answer the practical question: which models are actually good enough to rely on in production?</p>
</div>
<div>
<div class="callout-box">
<div class="callout-label">The core problem</div>
<div class="callout-text">"I'm fine." — spoken calmly vs. spoken through tears. The transcript is identical. The emotional signal is not.</div>
</div>
<div style="margin-top:1.5rem;background:var(--surface);padding:1.25rem 1.5rem">
<div style="font-size:10px;font-weight:700;letter-spacing:0.15em;text-transform:uppercase;color:var(--muted);margin-bottom:1rem">Cascading pipeline</div>
<div style="display:flex;flex-direction:column;gap:0.5rem;font-size:12.5px">
<div style="display:flex;align-items:center;gap:0.75rem"><span style="background:var(--ink);color:#f5f1eb;padding:0.2em 0.6em;font-size:11px;font-weight:600">Audio</span><span style="color:var(--faint)">→</span><span style="color:var(--muted)">Raw speech with emotional signal</span></div>
<div style="display:flex;align-items:center;gap:0.75rem;padding-left:1.5rem;border-left:2px solid var(--red)"><span style="font-size:11px;font-weight:600;color:var(--red)">SER model here</span><span style="color:var(--muted);font-size:11.5px">← only chance to read emotion</span></div>
<div style="display:flex;align-items:center;gap:0.75rem"><span style="background:var(--surface);border:1px solid var(--rule);padding:0.2em 0.6em;font-size:11px;font-weight:600">STT</span><span style="color:var(--faint)">→</span><span style="color:var(--muted)">Transcript — emotion gone</span></div>
<div style="display:flex;align-items:center;gap:0.75rem"><span style="background:var(--surface);border:1px solid var(--rule);padding:0.2em 0.6em;font-size:11px;font-weight:600">LLM</span><span style="color:var(--faint)">→</span><span style="color:var(--muted)">Response generation</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ WHAT WE EVALUATE ═══════════════════ -->
<div class="wrap">
<div class="blog-section">
<div class="blog-h2">What we're evaluating</div>
<div class="blog-body">
<div class="blog-prose">
<p>We evaluate ${modelCount} production speech-emotion APIs on <strong>273 real human voice recordings</strong> — not acted speech from professional voice actors. Speakers were asked to read emotionally neutral scripts (the content carries no inherent emotion) while expressing a target emotion purely through vocal delivery.</p>
<p>This design <strong>isolates prosody from semantics</strong>: the only signal available to each model is how something is said, not what is said. It reflects the hardest and most realistic version of the problem.</p>
<p>The dataset is <strong>balanced</strong>: exactly 39 clips per emotion, so accuracy metrics are not skewed by class frequency. We report <strong>macro accuracy</strong> (the mean of per-emotion accuracies) as the primary metric.</p>
</div>
<div class="eval-pills">
<div class="eval-pill">
<div class="eval-pill-label">Track 1 — 7-class emotion</div>
<div class="eval-pill-title">Angry · Disgusted · Fearful · Happy · Neutral · Sad · Surprised</div>
<div class="eval-pill-desc">The full discrete emotion task. Each model must classify a clip into one of seven categories. Baseline random accuracy: 14.3%.</div>
</div>
<div class="eval-pill">
<div class="eval-pill-label">Track 2 — 3-class valence</div>
<div class="eval-pill-title">Positive · Neutral · Negative</div>
<div class="eval-pill-desc">Emotions collapsed to sentiment polarity. Surprised clips are excluded (ambiguous valence). Baseline random accuracy: 33.3%. See Section 07 for results.</div>
</div>
<div class="eval-pill">
<div class="eval-pill-label">Dataset</div>
<div class="eval-pill-title">273 clips · 7 emotions · Real speakers</div>
<div class="eval-pill-desc">Balanced evaluation set sampled from ${audioCount.toLocaleString()} total recordings. All speakers consented to public release. Scripts were emotionally neutral by design.</div>
</div>
</div>
</div>
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ LEAD ═══════════════════ -->
<div class="wrap">
<div class="lead-section">
<p class="lead-statement">
${modelCount} speech-emotion models were tested across ${scored.toLocaleString()}&nbsp;scored clips.
The best achieved <strong>${best.accuracyStr}</strong> overall accuracy, while
<em>${hardestEmo.emotion}</em> remained the hardest emotion
to detect — ${hardestEmo.accuracyStr} overall.
</p>
<div class="lead-stats">
<div class="stat-row">
<div class="stat-num">${overallAccuracyStr}</div>
<div class="stat-desc"><strong>Overall accuracy</strong> across all models and emotions. ${correct.toLocaleString()} correct of ${scored.toLocaleString()} scored rows.</div>
</div>
<div class="stat-row">
<div class="stat-num">${easiestEmo.accuracyStr}</div>
<div class="stat-desc"><strong>Best emotion</strong> — ${easiestEmo.emotion}, the category where models performed most reliably.</div>
</div>
<div class="stat-row">
<div class="stat-num">${hardestEmo.accuracyStr}</div>
<div class="stat-desc"><strong>Worst emotion</strong> — ${hardestEmo.emotion}, only ${hardestEmo.correct.toLocaleString()} of ${hardestEmo.rows.toLocaleString()} examples correctly identified.</div>
</div>
</div>
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ LEADERBOARD ═══════════════════ -->
<div class="wrap">
<div class="section-header">
<span class="section-num">01</span>
<span class="section-title">Model Leaderboard</span>
</div>
<div class="leaderboard-grid">
<div class="leaderboard-table-wrap">
<table class="leaderboard-table">
<thead>
<tr>
<th></th>
<th>Model</th>
<th>Provider</th>
<th>Correct</th>
<th>Accuracy</th>
</tr>
</thead>
<tbody>
${leaderboardTable(modelSummaries)}
</tbody>
</table>
</div>
<div class="lb-chart-side">
<h3>Overall · Correct vs Incorrect</h3>
<div style="display:flex;align-items:center;gap:2rem">
<div class="donut-wrap">
<canvas id="pieOverall"></canvas>
<div class="donut-center">
<span class="donut-pct">${Math.round(analysis.overallAccuracy)}%</span>
<span class="donut-label">Accurate</span>
</div>
</div>
<ul class="legend-list">
<li class="legend-item">
<span class="legend-dot" style="background:#2c7a4e"></span>
Correct
<span class="legend-val">${correct.toLocaleString()}</span>
</li>
<li class="legend-item">
<span class="legend-dot" style="background:var(--rule)"></span>
Incorrect
<span class="legend-val">${(scored - correct).toLocaleString()}</span>
</li>
</ul>
</div>
</div>
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ EMOTION DIFFICULTY ═══════════════════ -->
<div class="wrap">
<div class="section-header">
<span class="section-num">02</span>
<span class="section-title">Emotion Difficulty — Hardest to Easiest</span>
</div>
<div class="emotion-section">
<div class="emotion-chart-wrap">
<canvas id="barEmotions"></canvas>
</div>
<table class="emotion-table">
<thead>
<tr>
<th>Emotion</th>
<th>Sample size</th>
<th>Correct</th>
<th>Accuracy</th>
</tr>
</thead>
<tbody>
${emotionTableRows(overallEmotions)}
</tbody>
</table>
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ MODEL × EMOTION ═══════════════════ -->
<div class="wrap">
<div class="section-header">
<span class="section-num">03</span>
<span class="section-title">Model Accuracy by Emotion</span>
</div>
<div class="model-section">
<div class="model-chart-wrap">
<canvas id="barGrouped"></canvas>
</div>
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ RADAR ═══════════════════ -->
<div class="wrap">
<div class="section-header">
<span class="section-num">04</span>
<span class="section-title">Strength Profile — All Models</span>
</div>
<div class="radar-section">
<div>
<div class="radar-wrap">
<canvas id="radarAll"></canvas>
</div>
</div>
<div style="padding-top:1rem">
<p style="font-size:13.5px;line-height:1.7;color:var(--muted);max-width:380px">
The radar reveals cross-model patterns: which emotions each model handles well
versus where they all collapse. Compare how newer models like
<strong style="color:var(--text)">${modelSummaries[0]?.meta.displayName || 'the top model'}</strong> differ from
established ones across the emotion spectrum.
</p>
<div style="margin-top:2rem">
<div style="font-size:10.5px;font-weight:600;letter-spacing:0.1em;text-transform:uppercase;color:var(--muted);padding-bottom:0.5rem;border-bottom:1px solid var(--rule);margin-bottom:0.75rem">Models</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:0.5rem 1.5rem">
${radarLegend}
</div>
</div>
</div>
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ PREDICTION BIAS ═══════════════════ -->
<div class="wrap">
<div class="section-header">
<span class="section-num">05</span>
<span class="section-title">Prediction Bias — What Each Model Gets Wrong</span>
</div>
<div class="bias-grid">
${biasGrid(modelSummaries)}
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ PER-MODEL DETAIL ═══════════════════ -->
<div class="wrap">
<div class="section-header">
<span class="section-num">06</span>
<span class="section-title">Per-Model Detail</span>
</div>
<div class="model-card-grid" style="margin-top:0">
${modelDetailGrid(modelSummaries)}
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ KEY TAKEAWAYS ═══════════════════ -->
<div class="wrap">
<div class="section-header">
<span class="section-num">07</span>
<span class="section-title">Results &amp; Key Takeaways</span>
</div>
<div class="takeaways-grid">
<div class="takeaway-card">
<div class="takeaway-num">01</div>
<div class="takeaway-title">No model is production-ready for all emotions</div>
<div class="takeaway-desc">The best model (${escHtml(best?.meta.displayName || '')}) hits <strong>${best?.accuracyStr}</strong> macro accuracy — about 3× random chance. But performance varies wildly by emotion: neutral detection is reliable, while fearful and disgusted hover near chance for most models.</div>
</div>
<div class="takeaway-card">
<div class="takeaway-num">02</div>
<div class="takeaway-title">Every model defaults to "neutral"</div>
<div class="takeaway-desc">Across all ${modelCount} models, the single most common error is predicting <strong>neutral</strong> when the true label is something else. This is a safe hedge that inflates performance on neutral-heavy datasets — but fails on the emotions that matter most in customer-facing applications.</div>
</div>
<div class="takeaway-card">
<div class="takeaway-num">03</div>
<div class="takeaway-title">Gemini leads, but the gap is narrow</div>
<div class="takeaway-desc"><strong>Google Gemini 3.5 Flash</strong> leads at ${best?.accuracyStr}, closely followed by Gemini 2.5 Flash and Hume AI Prosody. The top 4 models are within 6 percentage points of each other — meaning model choice alone is not a silver bullet.</div>
</div>
<div class="takeaway-card">
<div class="takeaway-num">04</div>
<div class="takeaway-title">Different models fail in different ways</div>
<div class="takeaway-desc"><strong>Hume Prosody</strong> uniquely excels at happy (64%) but scores 0% on fearful. <strong>Mistral Voxtral</strong> leads on disgusted (74%) but collapses on angry (16%). <strong>Inworld Voice</strong> tops neutral accuracy (96%) but barely registers surprised (4%). Ensemble approaches may outperform any single model.</div>
</div>
<div class="takeaway-card">
<div class="takeaway-num">05</div>
<div class="takeaway-title">Valence is more tractable than discrete emotion</div>
<div class="takeaway-desc">Collapsing to 3-class valence (positive / neutral / negative) significantly improves accuracy. <strong>${escHtml(modelValence[0]?.meta.displayName || '')}</strong> reaches ${modelValence[0]?.accuracyStr} on the valence task vs. ${best?.accuracyStr} on the 7-class task. For many agent use cases, valence alone may be sufficient.</div>
</div>
<div class="takeaway-card">
<div class="takeaway-num">06</div>
<div class="takeaway-title">Content-neutral scripts are harder than expected</div>
<div class="takeaway-desc">Our scripts were <strong>intentionally emotionally ambiguous</strong> in wording — no emotional vocabulary, no dramatic events. Models that rely on semantic cues from transcription cannot use them here. The signal is purely prosodic, which is the exact condition these models will face in production on real customer calls.</div>
</div>
</div>
</div>
<hr class="rule">
<!-- ═══════════════════ VALENCE ANALYSIS ═══════════════════ -->
<div class="wrap">
<div class="section-header">
<span class="section-num">08</span>
<span class="section-title">Valence Analysis — Positive / Neutral / Negative</span>
</div>
<p style="color:var(--muted);font-size:13px;margin-bottom:1.5rem">
Emotions collapsed to 3-class valence: <strong>positive</strong> (happy), <strong>negative</strong> (angry, disgusted, fearful, sad), <strong>neutral</strong>.
Clips with a gold label of <em>surprised</em> are excluded. Predicted <em>surprised</em> on remaining clips counts as incorrect.
Evaluated across ${valenceAudioCount.toLocaleString()} audio files&nbsp;·&nbsp;${valenceRows.toLocaleString()} scored rows.
</p>
<table class="emotion-table" style="margin-bottom:2rem">
<thead>
<tr><th>Rank</th><th>Model</th><th>Provider model</th><th>Correct / Files</th><th>Accuracy</th></tr>
</thead>
<tbody>
${valenceLeaderboard(modelValence)}
</tbody>
</table>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:2rem;margin-bottom:2rem">
<div>
<div style="font-size:11px;font-weight:600;letter-spacing:0.1em;text-transform:uppercase;color:var(--muted);margin-bottom:0.75rem">Accuracy by Gold Category (all models)</div>
<table class="emotion-table">
<thead><tr><th>Category</th><th>Rows</th><th>Correct</th><th>Accuracy</th></tr></thead>
<tbody>
${valByCatRows}
</tbody>
</table>
</div>
<div>
<div style="font-size:11px;font-weight:600;letter-spacing:0.1em;text-transform:uppercase;color:var(--muted);margin-bottom:0.75rem">Overall Confusion Matrix</div>
<table class="emotion-table">
<thead><tr><th>Actual \\ Predicted</th><th>Negative</th><th>Neutral</th><th>Positive</th><th>Total</th></tr></thead>
<tbody>
${valenceMatrixHtml(valenceMatrix)}
</tbody>
</table>
</div>
</div>
<div class="model-detail-grid" style="margin-top:0">
${perModelValenceGrid(modelValence)}
</div>
</div>
<hr class="rule">
<div class="wrap">
<footer>
<span>Track 1 Emotion Benchmark — Combined &nbsp;·&nbsp; <code>${escHtml(inputPath)}</code></span>
<span>${totalRows.toLocaleString()} total rows &nbsp;·&nbsp; ${scored.toLocaleString()} scored &nbsp;·&nbsp; ${errors} errors</span>
</footer>
</div>
${chartScript(analysis)}
</body>
</html>`
}
// ── Entry point ──────────────────────────────────────────────────────────────
function parseArgs(argv) {
const args = { input: DEFAULT_INPUT, output: DEFAULT_OUTPUT }
for (let i = 2; i < argv.length; i++) {
if (argv[i] === '--input' && argv[i + 1]) { args.input = argv[++i] }
else if (argv[i] === '--out' && argv[i + 1]) { args.output = argv[++i] }
else if (argv[i] === '--help' || argv[i] === '-h') {
console.log(`Usage: node scripts/analyze-track1-combined.cjs [--input <csv>] [--out <html>]`)
process.exit(0)
}
}
return args
}
function main() {
const args = parseArgs(process.argv)
const inputPath = path.resolve(args.input)
const outputPath = path.resolve(args.output)
console.log(`Reading: ${inputPath}`)
const rows = parseCsv(fs.readFileSync(inputPath, 'utf8'))
console.log(`Parsed ${rows.length} rows`)
const analysis = analyze(rows)
const html = buildHtml(analysis, args.input)
fs.mkdirSync(path.dirname(outputPath), { recursive: true })
fs.writeFileSync(outputPath, html, 'utf8')
console.log(`Written: ${outputPath}`)
console.log(JSON.stringify({
audioFiles: analysis.audioCount,
models: analysis.modelCount,
totalRows: analysis.totalRows,
scored: analysis.scored,
correct: analysis.correct,
errors: analysis.errors,
overallAccuracy: analysis.overallAccuracyStr,
topModel: analysis.modelSummaries[0]?.meta.displayName,
topModelAccuracy: analysis.modelSummaries[0]?.accuracyStr,
}, null, 2))
}
main()