JuliaDSP/MFCC.jl

`mfcc` returns NaNs when signal contains zeros

Closed this issue · 2 comments

I suppose this behaviour should be avoided:

julia> using MFCC

julia> X, = mfcc(zeros(1000));

julia> any(isnan.(X))
true

Adding a small constant fixes the problem:

julia> X, = mfcc(zeros(1000).+eps());

julia> any(isnan.(X))
false

not sure this is the common practice though...

it would be more numerically stable to clip than to add a constant. Or else consider the log1p function.

Librosa clips to -80 dB by default https://github.com/librosa/librosa/blob/ceb862f6117f959bda0ecc04f6891ea2c80b0ce0/librosa/core/spectrum.py#L1447

See #14