NeMo per_feature models: hard log floor log(max(fbank, FLT_EPSILON)) hurts quiet audio; NeMo uses log(x + 2^-24)
Summary
For NeMo models with normalize_type=per_feature (FastConformer CTC, Parakeet TDT), sherpa-onnx takes the log of the mel energies with kaldi-native-fbank's hard floor:
log(max(E, FLT_EPSILON)) // FLT_EPSILON ≈ 1.19e-7, samples in [-1, 1]NeMo's AudioToMelSpectrogramPreprocessor uses an additive guard instead (log_zero_guard_type="add", log_zero_guard_value=2**-24):
log(E + 2^-24)On recordings quieter than about −50 dBFS RMS, a large share of mel bins sit at the hard floor. After per-feature normalization those bands turn into constant columns with occasional spikes, which the models never saw in training. Accuracy drops a lot on such audio. Normal-level audio is unaffected.
Numbers
sherpa-onnx 1.13.8, Windows x64, int8 models, FLEURS dev, the first 100 clips per language in tar order. WER / CER %, text lowercased and punctuation removed.
I replicated sherpa's offline feature pipeline in Python: kaldi-native-fbank 1.22.3 with the options set in offline-recognizer-ctc-impl.h / offline-recognizer-transducer-nemo-impl.h, plus NemoNormalizePerFeature. The features go into the same ONNX graphs via onnxruntime. On fp32 models the replica's output tokens match sherpa's in 22 of 24 clips; the two exceptions are near-silent clips that come out garbled either way. "NeMo preprocessing" is onnx-asr's NemoPreprocessorNumpy. The FastConformer graphs are the OpenVoiceOS ONNX exports of the CTC branch, with sherpa metadata added.
| model, dataset | sherpa 1.13.8 features | same with log(E + 2^-24) |
NeMo preprocessing |
|---|---|---|---|
| parakeet-tdt_ctc-110m (en), en_us | 13.01 / 7.89 | 7.76 / 4.55 | 7.95 / 4.64 |
| stt_ua_fastconformer_hybrid_large_pc, CTC branch, uk_ua | 36.18 / 13.52 | 30.31 / 9.81 | 30.13 / 9.84 |
| stt_be_fastconformer_hybrid_large_pc, CTC branch, be_by | 13.98 / 6.26 | 14.19 / 6.29 | 14.04 / 6.22 |
| same, with 1 s of exact digital silence at start, middle and end: | |||
| parakeet-tdt_ctc-110m, en_us | 15.75 / 10.17 | 8.75 / 5.46 | 8.28 / 5.05 |
| stt_ua_fastconformer, uk_ua | 38.97 / 14.94 | 32.98 / 11.01 | 33.51 / 11.26 |
The real sherpa-onnx 1.13.8 Python wheel on the same clips gives en 12.72 / 7.85, uk 35.35 / 13.56 and be 13.93 / 6.20.
The effect follows the recording level. FLEURS en_us dev has a median level of −60 dBFS. On its 69 clips below −50 dBFS, WER goes 15.2 → 7.9 % once the floor is moved (input ×32768, real sherpa). On its 24 clips above −30 dBFS it stays put (5.7 → 6.1 %). be_by (median −39 dBFS) is unaffected.
I also swapped in every other difference between the two pipelines one at a time, starting from NeMo preprocessing. None of them matters, all are within noise:
- frame centering (
snip_edges=falsecenters frames ati*shift + shift/2,center=Trueati*shift) - periodic vs symmetric Hann window
- per-frame vs global preemphasis
- biased vs unbiased variance
features_length / subsampling_factoroutput length- on the transducer path, the povey window and
high_freq=-400(mel up to 7600 Hz): 7.95 / 4.55 and 7.85 / 4.71 against 7.95 / 4.64
The log floor alone accounts for the whole gap. NeMo preprocessing with only the hard floor swapped in gives 13.10 / 7.84 (en) and 35.59 / 13.81 (uk).
Workaround without code changes
Multiplying the input samples by 8 before accept_waveform works because per-feature normalization cancels the gain; it only moves the floor 18 dB down. With the real sherpa-onnx 1.13.8:
| model | ×1 | ×8 | ×32768 |
|---|---|---|---|
| parakeet-tdt_ctc-110m, en_us | 12.72 / 7.85 | 7.71 / 4.46 | 7.57 / 4.39 |
| stt_ua_fastconformer CTC, uk_ua | 35.35 / 13.56 | 29.30 / 9.46 | 30.13 / 9.85 |
| same, with digital silence | 39.21 / 15.35 | 31.14 / 10.04 | 59.79 / 27.56 |
| parakeet-tdt-0.6b-v3 int8, uk_ua | 11.98 / 3.77 | 11.45 / 3.59 | 11.68 / 3.72 |
| same, with digital silence | 15.07 / 5.34 | 12.16 / 3.36 | 24.73 / 9.50 |
Note that ×32768, which is what normalize_samples=false would do, is not a fix. With exact zeros in the audio, the zero frames land far below the speech and become outliers after normalization.
Suggested fix
For nemo_normalize_type == "per_feature", compute the fbank without the log and apply NeMo's guard before the normalization. This only touches NeMo per_feature models. GigaAM (empty normalize_type) and everything else stay as they are. A sketch for offline-stream.cc:
// OfflineStream::Impl ctor, fbank branch
if (config.nemo_normalize_type == "per_feature") {
// NeMo: log(mel + 2^-24), see AudioToMelSpectrogramPreprocessor
opts_.use_log_fbank = false;
}
// OfflineStream::Impl::GetFrames(), before NemoNormalizeFeatures()
if (!opts_.use_log_fbank && config_.nemo_normalize_type == "per_feature") {
constexpr float kGuard = 5.9604645e-08f; // 2^-24
for (auto &v : features) v = std::log(v + kGuard);
}This is exactly the "same with log(E + 2^-24)" column above.
Side notes
offline-stream.ccdoes not copypreemph_coefforround_to_power_of_twofromFeatureExtractorConfiginto the knf options (features.ccdoes). So the GigaAM branch'spreemph_coeff = 0andround_to_power_of_two = falseseem to have no effect in the offline API. I have not measured the impact.- #3767 (Parakeet TDT decoding to an empty string on 1.13.3 / 1.13.4) is likely the variance cancellation fixed in #3857. On 1.13.3 I saw the same mechanism: bands pinned at the log floor make
E[x^2] - E[x]^2collapse to 0, and normalized features reach about 1e5. For the Belarusian model on the first 12 be_by dev clips, 1.13.3 gave 25.5 % WER against 19.0 % on 1.13.8.
Source: k2-fsa/sherpa-onnx