Repository navigation
fix(auto): do not divide by zero speech time in AutoModel.inference - #3896
Merged
Merged
Conversation
Input shorter than one feature frame (about 25 ms) makes the model report batch_data_time == 0, and the rtf statistic then raised ZeroDivisionError after the model had already returned its (empty) result.
LauraGPT
added a commit
that referenced
this pull request
Nov 14, 2026
Preserve original #3896 ancestry. Scoped private suites and real native CUDA evidence; exact NumPy/KWS/MOSS CI accepted. Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AutoModel.inferencecomputestime_escape / batch_data_timefor its rtf statistic after the model has already returned its result. fsmn-vad reportsbatch_data_time == 0when a call produces no feature frame, so the statistic raisedZeroDivisionErrorand the result was lost. This happens for one-shot inputs shorter than 400 samples (25 ms at 16 kHz) and for streaming VAD withchunk_size=10or20ms, where the first chunk produces no frame. The progress-barrtf_avgdescription has the same division. Both now reportnanwhen no speech time was reported. Models that report-1(no timing) keep the previous value (code reading).Type of change
Validation
python -m compileall funasr examples testspython -m pytest tests/test_auto_model_zero_speech_time.py -q: 2 failed on main (ZeroDivisionErrorat auto_model.py:986), 2 passed with the fix.iic/speech_fsmn_vad_zh-cn-16k-common-pytorch), CPU:generate(input=wav[:n]): main raises for n <= 399 and works from n = 400 (bisected); with the fix n = 100 and 399 returnvalue: [].cache,is_final) over the first 20 s ofexample/vad_example.wav: on mainchunk_size=10and20raise at the first chunk, 30 ms and larger work. With the fix 10 and 20 ms give the same events as 200 ms ([[70, -1], [-1, 19980]]).generate(input=[wav_20s, wav[:100]]): main raises and returns nothing; with the fix the 20 s input gets[[70, 19980]].AutoModel(model=..., vad_model=<fsmn-vad>)on 100 samples: main raises in the VAD step; with the fix it returns{'text': '', 'timestamp': []}. VAD finds no segment, so the second model is never called (fsmn-vad stood in for the ASR model).User impact
Streaming VAD with 10 or 20 ms chunks (common audio-callback sizes), very short clips, and batches or VAD+ASR pipelines that contain such a clip no longer crash. A too-short input returns an empty result, as
funasr_onnxdoes since #3822.Notes for reviewers
inference_with_vadwith a 1e-6 floor).nanis used here because a per-batch rtf with no speech time is undefined.(samples, channels)array also reaches this division today: fsmn-vad sees no frame and raises the sameZeroDivisionError. With this change alone such input returns an empty result instead of raising. Open fix(audio): average the channels of 2-D waveform arrays and tensors #3891 averages 2-D arrays to mono; with it, such input returns the normal segments.