isSilent
Detects whether an audio buffer contains silence.
function isSilent(samples, threshold?): boolean;
Defined in: src/utils/audio.ts:428
Detects whether an audio buffer contains silence.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
samples | Float32Array | undefined | The audio samples as a Float32Array (normalized to [-1.0, 1.0]). |
threshold | number | 0.01 | The RMS threshold below which audio is considered silent. |
Returns
boolean
true if the RMS volume is below the threshold, false otherwise.
Remarks
Computes the RMS volume via calculateRMS and compares it against the given threshold. Useful for detecting end-of-speech or filtering out background noise.
Default Value
threshold: 0.01
Example
if (isSilent(audioBuffer, 0.02)) {
console.log('Silence detected -- end of speech?');
}