diff --git a/modules/audio_processing/ns/ns_core.c b/modules/audio_processing/ns/ns_core.c index 3345b2451e..c87713acaf 100644 --- a/modules/audio_processing/ns/ns_core.c +++ b/modules/audio_processing/ns/ns_core.c @@ -1081,6 +1081,7 @@ void WebRtcNs_AnalyzeCore(NoiseSuppressionC* self, const float* speechFrame) { // Depending on the duration of the inactive signal it takes a // considerable amount of time for the system to learn what is noise and // what is speech. + self->signalEnergy = 0; return; } @@ -1239,7 +1240,7 @@ void WebRtcNs_ProcessCore(NoiseSuppressionC* self, Windowing(self->window, self->dataBuf, self->anaLen, winData); energy1 = Energy(winData, self->anaLen); - if (energy1 == 0.0) { + if (energy1 == 0.0 || self->signalEnergy == 0) { // Synthesize the special case of zero input. // Read out fully processed segment. for (i = self->windShift; i < self->blockLen + self->windShift; i++) { @@ -1379,6 +1380,7 @@ void WebRtcNs_ProcessCore(NoiseSuppressionC* self, sumMagnAnalyze += self->magnPrevAnalyze[i]; sumMagnProcess += self->magnPrevProcess[i]; } + RTC_DCHECK_GT(sumMagnAnalyze, 0); avgProbSpeechHB *= sumMagnProcess / sumMagnAnalyze; // Average filter gain from low band. // Average over second half (i.e., 4->8kHz) of frequencies spectrum. diff --git a/modules/audio_processing/ns/ns_core.h b/modules/audio_processing/ns/ns_core.h index 97f76baf0d..990d363223 100644 --- a/modules/audio_processing/ns/ns_core.h +++ b/modules/audio_processing/ns/ns_core.h @@ -110,7 +110,6 @@ typedef struct NoiseSuppressionC_ { float speechProb[HALF_ANAL_BLOCKL]; // Final speech/noise prob: prior + LRT. // Buffering data for HB. float dataBufHB[NUM_HIGH_BANDS_MAX][ANAL_BLOCKL_MAX]; - } NoiseSuppressionC; #ifdef __cplusplus