#!/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, '&') .replace(//g, '>') } // ── 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 `` } function modelDot(meta, size = 9) { return `` } 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 `
| Actual \\ Predicted | Negative | Neutral | Positive | Total |
|---|
Most AI voice agents today use a cascading architecture: 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.
When audio becomes text, all prosodic information is lost: 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.
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 — you need a dedicated speech emotion recognition model running on the raw audio, before transcription.
This benchmark exists to answer the practical question: which models are actually good enough to rely on in production?
We evaluate ${modelCount} production speech-emotion APIs on 273 real human voice recordings — 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.
This design isolates prosody from semantics: 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.
The dataset is balanced: exactly 39 clips per emotion, so accuracy metrics are not skewed by class frequency. We report macro accuracy (the mean of per-emotion accuracies) as the primary metric.
${modelCount} speech-emotion models were tested across ${scored.toLocaleString()} scored clips. The best achieved ${best.accuracyStr} overall accuracy, while ${hardestEmo.emotion} remained the hardest emotion to detect — ${hardestEmo.accuracyStr} overall.
| Model | Provider | Correct | Accuracy |
|---|
| Emotion | Sample size | Correct | Accuracy |
|---|
The radar reveals cross-model patterns: which emotions each model handles well versus where they all collapse. Compare how newer models like ${modelSummaries[0]?.meta.displayName || 'the top model'} differ from established ones across the emotion spectrum.
Emotions collapsed to 3-class valence: positive (happy), negative (angry, disgusted, fearful, sad), neutral. Clips with a gold label of surprised are excluded. Predicted surprised on remaining clips counts as incorrect. Evaluated across ${valenceAudioCount.toLocaleString()} audio files · ${valenceRows.toLocaleString()} scored rows.
| Rank | Model | Provider model | Correct / Files | Accuracy |
|---|
| Category | Rows | Correct | Accuracy |
|---|
| Actual \\ Predicted | Negative | Neutral | Positive | Total |
|---|