Add ffmpeg fallback for audio formats libsndfile cannot decode (M4A/AAC) - #1267
Open
GuxtavoLiu wants to merge 1 commit into
Open
Add ffmpeg fallback for audio formats libsndfile cannot decode (M4A/AAC)#1267GuxtavoLiu wants to merge 1 commit into
GuxtavoLiu wants to merge 1 commit into
Conversation
Uploading M4A/AAC recordings (the default format of the Windows Sound Recorder and WhatsApp voice notes) fails at inference with 'Format not recognised' because libsndfile cannot decode AAC. When soundfile fails to open a file, decode it with ffmpeg instead (mono float32 at the requested sample rate). Behavior is unchanged for formats libsndfile already handles and for systems without ffmpeg on PATH, which re-raise the original error. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
|
If this does what you say it does, that sounds awesome! I haven't reviewed the code, but thanks. |
Contributor
|
Honestly, the audio load should be done using ffmpeg as it does not zap the top end of the audio spectrum. |
Member
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.
Problem
Uploading an M4A/AAC file to inference fails with:
M4A is the default output of the Windows Sound Recorder and of WhatsApp voice notes, so this is a common first experience for new users: they record something, upload it, and conversion fails with a generic error.
Root cause:
load_audio/load_audio_inferread files with soundfile (libsndfile), which does not decode AAC.Fix
Add a small
read_audio_anyhelper inrvc/lib/utils.py: trysf.readfirst and, if libsndfile cannot open the file, decode it with ffmpeg (mono float32 at the requested sample rate, piped via stdout, no temp files).sf.readstill handles those.LibsndfileErroris re-raised, so systems without ffmpeg see the same error as today.Testing
Tested on Windows 11 (RTX 3060, CUDA build) by running
core.py inferwith an M4A recording from the Windows Sound Recorder: fails with 'Format not recognised' before the patch, converts normally after it. Also verified that WAV inference still works unchanged.🤖 Generated with Claude Code