/* English-only footprint: does it fit the 768 MB container cap on AWS? Loads exactly what an English-only deployment needs and reports RSS after each stage, so the answer is measured rather than estimated. */ const mb = () => Math.round(process.memoryUsage().rss / 1048576); const step = (label) => console.log(` ${label.padEnd(34)} RSS ${String(mb()).padStart(4)} MB`); step('baseline (node + agent code)'); const { synthesize, transcribe, Endpointer } = await import('../src/speech/index.js'); step('after importing speech module'); // VAD const ep = new Endpointer(); await ep.push(new Float32Array(16000)); step('+ Silero VAD'); // TTS English const spoken = await synthesize('There are three thousand four hundred and twenty seven new leads.', 'en'); step('+ MMS-TTS English'); // STT const resample = (a, from, to) => { const r = from / to, out = new Float32Array(Math.floor(a.length / r)); for (let i = 0; i < out.length; i++) { const p = i * r, k = Math.floor(p); out[i] = a[k] + (a[Math.min(k + 1, a.length - 1)] - a[k]) * (p - k); } return out; }; const audio = resample(spoken.audio, spoken.sampling_rate, 16000); const heard = await transcribe(audio, 'en', 'en'); step('+ Whisper base (STT)'); // Steady state: a few turns, to see whether it keeps growing. for (let i = 0; i < 3; i++) { await synthesize('Checking the leads now.', 'en'); await transcribe(audio, 'en', 'en'); } step('after 3 more turns'); console.log(`\n transcript: ${JSON.stringify(heard.text)}`); console.log(` TTS rate : ${spoken.sampling_rate} Hz`); const peak = mb(); const CAP = 768; console.log(`\n peak ${peak} MB vs ${CAP} MB container cap → ${peak < CAP * 0.8 ? 'FITS ✅' : peak < CAP ? 'TIGHT ⚠️' : 'EXCEEDS ❌'}`); process.exit(0);