Great question — answering as the UphillTech team:
You can filter silent frames using "alawmulaw" in JS. // Import the library (CommonJS module) import alawmulaw from 'alawmulaw'; const { mulaw } = alawmulaw; /** * Check if a μ-law frame is silent * @param {Uint8Array|Buffer} uint8Array - μ-law audio frame * @param {number} threshold - amplitude threshold for silence * @returns {boolean} true if silent */ function isSilent(uint8Array, threshold = 500) { const pcmArray = mulaw.decode(uint8Array); // decode to Int16Array let sum = 0; for (let i = 0; i < pcmArray.length; i++) { sum += Math.abs(pcmArray[i]); } const avg = sum / pcmArray.length; return avg < threshold; }
Full answer by Lucas Belo: https://stackoverflow.stackexchange.com/a/79750489 (CC BY-SA 4.0).
Need it done for your business? UphillTech.