Live sermon translation into 100+ languages, running entirely on one Mac per campus: audio in, voice detection, Whisper on the GPU, NLLB-200 in its own process, and a built-in web server the congregation reads from on their phones. No audio leaves the building. This is the source only. What used to sit beside it — 14 GB of speech and translation models, 8 GB of voice bundles, 6 GB of natural voices, the Electron caches, and the app data holding the operator PIN and every service transcript — is machine state and downloaded assets, and stays in the NAS backup where it belongs. The vendored node, cloudflared and Windows ffmpeg binaries are out too (533 MB, re-fetched for packaging); the browser-side runtime beside them is kept, so a checkout still serves the congregation page. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
53 lines
3.4 KiB
JavaScript
53 lines
3.4 KiB
JavaScript
/* Unit-test the guard against MEASURED NLLB output — no model needed. */
|
|
const G = require('./mt-guard.js');
|
|
let pass = 0, fail = 0;
|
|
const t = (label, src, tgt, wantText, wantTrim) => {
|
|
const r = G.clean(src, tgt);
|
|
const ok = r.text === wantText && (wantTrim === undefined || r.trimmed === wantTrim);
|
|
console.log((ok ? ' PASS ' : ' FAIL ') + label);
|
|
if (!ok) console.log(' got "' + r.text + '" trimmed=' + r.trimmed +
|
|
'\n want "' + wantText + '"');
|
|
if (r.reason && ok) console.log(' ' + r.reason);
|
|
ok ? pass++ : fail++;
|
|
};
|
|
|
|
console.log('\nMEASURED HALLUCINATIONS — must be trimmed');
|
|
t('invented question', 'Donald Trump.', 'Donald Trump. ¿Qué es eso?', 'Donald Trump.', true);
|
|
t('subtitle dash', 'Hello, hello.', '- Hola, está bien.', 'Hola, está bien.', true);
|
|
/* One English word cannot mean two clauses, so everything after the comma is
|
|
invented. (In production liturgy.js answers "Amen." before the guard runs;
|
|
this fixture exercises the rule itself.) */
|
|
t('one-word clause trim', 'Amen.', '- Sí, estoy bien. ¿Y tú?', 'Sí.', true);
|
|
t('two words keeps its comma', 'God is good.', 'Dios es bueno, muy bueno.', 'Dios es bueno, muy bueno.', false);
|
|
t('CJK invented', 'Donald Trump.', '唐纳德·特朗普。那是什么?', '唐纳德·特朗普。', true);
|
|
t('Arabic invented', 'Amen.', 'آمين. ما هذا؟', 'آمين.', true);
|
|
|
|
console.log('\nMUST NOT BE TOUCHED — real output');
|
|
t('real question kept', 'How many countries are in the world?', '¿Cuántos países hay en el mundo?',
|
|
'¿Cuántos países hay en el mundo?', false);
|
|
t('unpunctuated tag question', 'Are you with me', '¿Estás conmigo?', '¿Estás conmigo?', false);
|
|
t('THE risk case', 'Can I get an amen', '¿Puedo recibir un amén?', '¿Puedo recibir un amén?', false);
|
|
t('semicolon scripture', 'The Lord is my shepherd; I shall not want.',
|
|
'El Señor es mi pastor; nada me faltará.', 'El Señor es mi pastor; nada me faltará.', false);
|
|
t('two in two out', 'Jesus wept. He loved him.', 'Jesús lloró. Lo amaba.', 'Jesús lloró. Lo amaba.', false);
|
|
t('abbreviation', 'Dr. Luke wrote it.', 'El Dr. Lucas lo escribió.', 'El Dr. Lucas lo escribió.', false);
|
|
t('decimal', 'Read John 3.16 with me.', 'Lee Juan 3.16 conmigo.', 'Lee Juan 3.16 conmigo.', false);
|
|
|
|
console.log('\nLONG SOURCE — clamp must NOT apply (legitimate splitting)');
|
|
t('long splits legitimately',
|
|
'For God so loved the world that he gave his only begotten Son, that whoever believes in him should not perish but have everlasting life.',
|
|
'Porque tanto amó Dios al mundo que dio a su Hijo unigénito. Para que todo el que crea en él no se pierda. Sino que tenga vida eterna.',
|
|
'Porque tanto amó Dios al mundo que dio a su Hijo unigénito. Para que todo el que crea en él no se pierda. Sino que tenga vida eterna.', false);
|
|
t('long keeps dash strip',
|
|
'And God said let there be light and there was light in the whole world today.',
|
|
'- Y dijo Dios: que haya luz.', 'Y dijo Dios: que haya luz.', true);
|
|
|
|
console.log('\nEDGE CASES');
|
|
t('empty target', 'Amen.', '', '', false);
|
|
t('target is only a dash', 'Amen.', '-', '-', false);
|
|
t('no source punctuation', 'Turn with me', 'Ven conmigo. ¿Qué es eso?', 'Ven conmigo.', true);
|
|
t('CJK no spaces in target', 'Praise the Lord.', '赞美主。', '赞美主。', false);
|
|
|
|
console.log('\n' + pass + ' passed, ' + fail + ' failed');
|
|
process.exit(fail ? 1 : 0);
|