Skip to content

Commit bd13036

Browse files
authored
[src] Update wav-reverberate.cc to avoid divide by zero. (#4668)
Update wav-reverberate.cc to avoid dividing by zero when noise_power is zero.
1 parent 3b91c76 commit bd13036

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/featbin/wav-reverberate.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ float DoReverberation(const Vector<BaseFloat> &rir, BaseFloat samp_freq,
104104
void AddNoise(Vector<BaseFloat> *noise, BaseFloat snr_db,
105105
BaseFloat time, BaseFloat samp_freq,
106106
BaseFloat signal_power, Vector<BaseFloat> *signal) {
107-
float noise_power = VecVec(*noise, *noise) / noise->Dim();
107+
float noise_power = VecVec(*noise, *noise) / noise->Dim() + FLT_EPSILON;
108108
float scale_factor = sqrt(pow(10, -snr_db / 10) * signal_power / noise_power);
109109
noise->Scale(scale_factor);
110110
KALDI_VLOG(1) << "Noise signal is being scaled with " << scale_factor

0 commit comments

Comments
 (0)