Session, Per-Frame Stats
KrispSDK constructor arguments
Property | Type | Default | Description |
---|---|---|---|
params.enableSessionStats | Boolean | false | Retrieves noise and voice statistics calculated from the start of NC processing. |
sessionStatsIntervalMS | Number | 1000 | The recommended frequency for retrieving session stats is 200ms or more. |
enablePerFrameStats | Boolean | false | Retrieves per-frame energy information returned after NC processing of the given frame. |
perFrameStatsCountInterval | Number | 100 | Frequency of frames for retrieving per frame stats. |
cosnt krispSDK = new KrispSDK({
params: {
// ...
enableSessionStats: true,
enablePerFrameStats: true,
sessionStatsIntervalMS: 1000,
perFrameStatsCountInterval: 200,
}
});
Register Session Stats event
Subscribe to the session stats event to receive periodic updates about noise and voice statistics during Noise Cancellation (NC) processing. The callback will be triggered at intervals defined by the sessionStatsIntervalMS
parameter.
filterNode.addEventListener("on_session_stats", (event) => {
/**
* Event data containing noise and voice statistics.
* @typedef {Object} SessionStatsEventData
* @property {Object} noiseEnergy - Noise statistics based on noise intensity levels.
* @property {number} noiseEnergy.noNoiseMs - Duration of no noise in milliseconds.
* @property {number} noiseEnergy.lowNoiseMs - Duration of low-intensity noise in milliseconds.
* @property {number} noiseEnergy.mediumNoiseMs - Duration of medium-intensity noise in milliseconds.
* @property {number} noiseEnergy.highNoiseMs - Duration of high-intensity noise in milliseconds.
* @property {number} noiseEnergy.cleanedSecondarySpeechMs - Duration of cleaned secondary speech in milliseconds.
* @property {number} noiseEnergy.cleanedSecondarySpeechNotDetectedMs - Duration when no cleaned secondary speech was detected.
* @property {number} noiseEnergy.cleanedSecondarySpeechUndefinedMs - Duration of undefined cleaned secondary speech.
* @property {Object} voiceEnergy - Voice statistics based on detected voice activity.
* @property {number} voiceEnergy.talkTimeMs - Duration of detected voice in milliseconds.
*/
console.log("on_session_stats", event.data);
});
Register Per-Frame Stats Event
Subscribe to the per-frame stats event to retrieve energy information for individual frames processed by the Noise Cancellation (NC) filter. The callback will be triggered based on the perFrameStatsCountInterval
parameter.
filterNode.addEventListener("on_per_frame_stats", (event) => {
/**
* @typedef {Object} PerFrameStats
* @property {Object} CleanedSecondarySpeechStatus - Cleaned secondary speech status enum. BVC specific feature.
* Returns the state of the removed secondary speech.
* If secondary speech is detected and removed, it returns Detected otherwise, it returns NotDetected.
* Undefined will be returned in case of running the NC.
* @property {number} event.data.cleanedSecondarySpeechStatus.value 0 - Cleaned secondary speech algorithm is not available (if non-BVC model provided).
* @property {number} event.data.cleanedSecondarySpeechStatus.value 1 - Cleaned secondary speech detected in the processed frame.
* @property {number} event.data.cleanedSecondarySpeechStatus.value 2 - Cleaned secondary speech is not detected in the processed frame.
*
* @property {Object} EnergyInfo - Energy information.
* @property {number} event.data.energyInfo.voiceEnergy - Voice energy level, range [0,100].
* @property {number} event.data.energyInfo.noiseEnergy - Noise energy level, range [0,100].
*/
console.log("on_per_frame_stats", event.data);
});
Updated 8 days ago