Files
christianandClaude Opus 5 c9eef0672c Church Translate, as it runs at the campuses
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>
2026-09-23 15:41:21 -04:00

26 lines
1.3 KiB
JavaScript

import { pipeline, env } from '@huggingface/transformers';
import { createRequire } from 'module';
import os from 'os'; import path from 'path';
const require = createRequire(import.meta.url);
const Guard = require('./mt-guard.js');
const B = require('./bible-lexicon.js');
env.allowLocalModels = false;
env.cacheDir = path.join(os.homedir(), 'Library/Application Support/Church Translate Models');
const pipe = await pipeline('translation', 'Xenova/nllb-200-distilled-600M', { dtype: 'fp32' });
const say = async (t, l) => {
const o = await pipe(t, { src_lang: 'eng_Latn', tgt_lang: l });
return (Array.isArray(o) ? o[0] : o).translation_text.trim();
};
const lex = B.forLanguage('spa_Latn');
const BARE = ['Peter.','John.','Matthew.','Noah.','Paul.','Moses.','David.','Abraham.','Jesus.','Mary.','Habakkuk.','Genesis.','Romans.','Peter','John'];
console.log('a BARE NAME as the whole utterance:\n');
for (const t of BARE) {
const raw = await say(t, 'spa_Latn');
const g = Guard.clean(t, raw);
const bare = t.replace(/\.$/, '');
const want = lex[bare] || bare;
const kept = g.text.toLowerCase().indexOf(want.toLowerCase()) !== -1 ||
g.text.toLowerCase().indexOf(bare.toLowerCase()) !== -1;
console.log(' ' + t.padEnd(12) + 'NLLB: ' + raw.padEnd(32) + 'after guard: ' + g.text.padEnd(26) + (kept ? '' : '<-- NAME LOST'));
}