fix(asr)cache-aware streaming: mono audio and variables UnboundLocalError - #16167
fix(asr)cache-aware streaming: mono audio and variables UnboundLocalError#16167YCmove wants to merge 2 commits into
Conversation
62b1ba2 to
4ab8634
Compare
| samples = librosa.core.resample(samples, orig_sr=f.samplerate, target_sr=target_sr) | ||
| samples = samples.transpose() | ||
| return samples | ||
| return librosa.load(audio_file, sr=target_sr, mono=True, dtype=dtype)[0] |
There was a problem hiding this comment.
revert this, we used soundfile as its multiple times faster than librosa. What is the motivation for this change?
There was a problem hiding this comment.
This is more about the stereo audio not being handled correctly.
-
librosa resamples the stereo audio in the wrong dimension
resample takes input format as np.ndarray [shape=(n,) or shape=(2, n)], whereas soundfile reads stereo as a two-dimensional array in (n, 2). This works fine for mono because soundfile reads mono as a one-dimensional array (n,) by default.
samples = samples.transpose()seems to be unnecessary, the transpose of (n,) is still (n,) -
This causes errors downstream in streaming_utils.py,
- audio_signal_len=2 instead of n
- incorrect format for audio_signal to pass into the preprocessor: (1, 2, n) instead of (batch, n)
I roll back to the original sf.SoundFile but add code to convert stereo to mono.
…hen single audio_file is used Signed-off-by: yuc <y8765gd@gmail.com>
Signed-off-by: yuc <y8765gd@gmail.com>
c448480 to
f7f2aa9
Compare
What does this PR do ?
Collection: asr
Changelog
output_pathis specified withoutdataset_manifest.audio_filein mono.Usage
Feed the mono or stereo audio_file to
examples/asr/asr_cache_aware_streaming/speech_to_text_cache_aware_streaming_infer.py.Test Environments: RTX 3090, CUDA Version: 13.2, Ubuntu 26.04, torch 2.12.0+cu132
Verification
Following tests are passed without warning:
GitHub Actions CI
The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.
Trusted PRs run automatically through copy-pr-bot. For an untrusted PR, a maintainer can trigger CI by commenting
/ok to test <head-sha>; repeat this after a new push if the PR remains untrusted.Before your PR is "Ready for review"
Pre checks:
PR Type:
Who can review?
@nithinraok or the previous author @artbataev
Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.
Additional Information
None