fix: auto-resample audio to 24kHz instead of asserting#233
Open
haosenwang1018 wants to merge 2 commits intoQwenLM:mainfrom
Open
fix: auto-resample audio to 24kHz instead of asserting#233haosenwang1018 wants to merge 2 commits intoQwenLM:mainfrom
haosenwang1018 wants to merge 2 commits intoQwenLM:mainfrom
Conversation
The speaker_encoder weights were explicitly deleted from the state dict before saving checkpoints (lines 150-153). When resuming training from a checkpoint, model.speaker_encoder becomes None, causing a crash on the first forward pass. Keep speaker_encoder in checkpoints so that training can resume correctly. Users who want smaller inference-only models can strip these weights separately. Fixes QwenLM#204 (bug 1)
The extract_mels method crashes with an assertion error when audio is not exactly 24kHz. Since librosa is already imported and used for loading, automatically resample to 24kHz instead of failing. This gives users a clear, working path without requiring manual audio preprocessing. librosa.resample uses high-quality resampling by default. Related to QwenLM#204 (bug 2)
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
extract_mels()infinetuning/dataset.pycrashes withAssertionError: Only support 24kHz audiowhen training data uses a different sample rate (e.g. 16kHz, 44.1kHz, 48kHz). This fails deep into training with no early warning or helpful error message.Related to #204 (bug 2: "No sample rate validation until runtime")
Fix
Replace the assert with automatic resampling via
librosa.resample(), which is already imported and used elsewhere in the module. High-quality resampling is applied transparently, and the target rate (24000) is enforced before mel extraction.Changes
finetuning/dataset.py: Replaceassert sr == 24000with automatic resample whensr != 24000