Repository navigation
fix(onnx): load non-.wav audio paths with librosa instead of pydub - #3865
Merged
Merged
Conversation
load_data in the funasr_onnx Paraformer (inherited by ContextualParaformer and SeacoParaformer), streaming Paraformer, Fsmn_vad and SenseVoiceSmall sent every path that does not end in .wav through pydub.AudioSegment.from_mp3, exported the result to <stem>.wav next to the input and loaded that file. pydub is not a funasr-onnx dependency, so on a clean install every .mp3, .flac or .ogg path raised ModuleNotFoundError: No module named 'pydub', also for the en.mp3 input of demo_sencevoice_small.py. With pydub but without ffmpeg, the conversion only printed its exception and the wrapper then loaded <stem>.wav: a FileNotFoundError for a file that was never passed or, when a different <stem>.wav sat next to the input, that recording, without an error. librosa, already a dependency, reads these formats through soundfile and falls back to audioread for files libsndfile cannot decode. Drop the conversion and load every path with librosa.load, as funasr_torch and Fsmn_vad_online already do. Extend tests/test_runtime_eval_native.py: for FLAC, OGG and MP3 files next to a different <stem>.wav, the load_data of each wrapper must return librosa.load(path, sr=16000), the native-fixture Paraformer must decode the path like the loaded waveform, and no file in the directory may change.
LauraGPT
reviewed
Nov 10, 2026
LauraGPT
left a comment
Collaborator
There was a problem hiding this comment.
Validated exact head a3b21c4ef3485780c389e2eddff789df05f24b84 against base 20f26b7c4905d010768ec91206149df2a90104b6.
- Baseline with the new regression: 3 failed (FLAC/OGG/MP3, missing pydub); exact head: 55 passed across
test_runtime_eval_cli.pyandtest_runtime_eval_native.py. - Real NVIDIA L20Z validation used ONNX Runtime 1.23.2 with
CUDAExecutionProvider: the synthetic native fixture produced identical results for the requested FLAC path and its loaded waveform, with 10 CUDA nodes / 0 CPU nodes in the profile. The neighboring same-stem WAV and input bytes were unchanged. - Exact-head hosted checks are green: Python 3.11/3.12 and runtime-eval 3.10/3.12.
Scope: synthetic fixture and wrapper/runtime behavior only; no pretrained weights, external network, ASR-quality, Nano, or production-service claim.
Merged
LauraGPT
added a commit
that referenced
this pull request
Nov 11, 2026
Publish the already accepted #3865 standalone wrapper fixes with hosted regression coverage. Signed-off-by: LauraGPT <zhifu.gzf@alibaba-inc.com>
LauraGPT
added a commit
that referenced
this pull request
Nov 11, 2026
Accept tested standalone package bytes and the already accepted exact-source #3865 runtime evidence. 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
Fixes #3864
In
funasr_onnx,load_datasends every path that does not end in.wavthroughpydub.AudioSegment.from_mp3, exports the result to<name>.wavnext to the input and loads that file. #2159 and #2186 added this toParaformer(inherited byContextualParaformerandSeacoParaformer), the streamingParaformer,Fsmn_vadandSenseVoiceSmall..mp3,.flacor.oggpath raisesModuleNotFoundError: No module named 'pydub', including theen.mp3ofdemo_sencevoice_small.py.转换失败:.... The wrapper then raisesFileNotFoundErrorfor<name>.wav, a file that was never passed. If a different<name>.wavis in the same folder, it loads that file with no error.from_mp3forces the MP3 demuxer, so.flac,.oggand.m4apaths still fail the same way (ffmpeg:Invalid data found when processing input). Only.mp3converts, and its export overwrites any existing<name>.wavnext to the input.Repro without model files (the full script is in the issue): for a 3 s
talk.flac,Paraformer.__new__(Paraformer).load_data("talk.flac", 16000)raises theModuleNotFoundError. With pydub 0.25.1, no ffmpeg and a 1 stalk.wavin the folder, it returns 16000 samples instead of 48000.librosa is already a dependency. It reads these formats through soundfile and falls back to audioread for files soundfile cannot open. This PR deletes the conversion (the wrapper diff only removes lines), so these wrappers load every path with
librosa.load(path, sr=fs), asfunasr_torchandFsmn_vad_onlinealready do..wavpaths and arrays load as before.The test,
test_onnx_wrappers_read_non_wav_pathsintests/test_runtime_eval_native.py, writes FLAC, OGG and MP3 files with soundfile next to a different 1 stalk.wav. It checks that:load_dataof all six wrappers equalslibrosa.load(path, sr=16000);Paraformerdecodes the path the same way as the loaded waveform;Formats the installed libsndfile cannot write are skipped.
test-runtime-eval.ymlalready runs this file forfunasr_onnxchanges.Type of change
Validation
Windows 11, CPU, Python 3.11.17 with torch 2.10.0+cpu, numpy 2.4.6, onnx 1.19.0, onnxruntime 1.23.2, librosa 0.11.0 and soundfile 0.14.0 (libsndfile 1.2.2). Neither pydub nor ffmpeg was installed, except where noted: the pydub-and-ffmpeg results above and the
.m4acheck below used ffmpeg 8.1.3 onPATH.main(20f26b7) with the new test: 3 failed, 52 passed, all three failures withModuleNotFoundError: No module named 'pydub'. With pydub 0.25.1 on the path, the same 3 tests fail becauseload_datareturns the 16000 samples oftalk.wav.I also installed funasr-onnx built from this branch into a fresh Python 3.12.15 venv with numpy 1.26.4 and onnxruntime 1.23.2, without torch or pydub:
The funasr-onnx package workflow's test scripts pass. On Windows,
test_funasr_onnx_release.pyneedsPYTHONUTF8=1, onmaintoo.The six wrappers'
load_datareturnslibrosa.load(path, sr=16000)for FLAC, OGG and MP3 paths. The package built frommainraises theModuleNotFoundErrorinstead.python -m compileall funasr examples testsDocs or links checked
Runtime/deployment command tested (above)
black --line-length=100(24.4.0) leaves the test unchanged, andgit diff --checkis clean.User impact
funasr_onnxusers can pass.mp3,.flacor.oggpaths without installing pydub and ffmpeg (the SenseVoiceSmall demo'sen.mp3, for example). They get the audio of the file they passed, and nothing is written next to it.Notes for reviewers
funasr_torchandFsmn_vad_onlinealready rely on it the same way), which can use ffmpeg, the same tool pydub needed. With ffmpeg onPATH, this branch decodes an AAC.m4apath that way, equal tolibrosa.load; without ffmpeg, that file raises audioread'sNoBackendError.funasr_torch,Fsmn_vad_onlineand every__call__. Thesensevoice_bin.pyhunk is only inload_data, and it merges cleanly with fix(runtime): honor use_itn in funasr_onnx and funasr_torch SenseVoiceSmall #3860 and fix(runtime): honor SenseVoice ITN and preserve mixed batch query tags #3861.