From cdd900e6a793dec925b857446ee263aca69aec10 Mon Sep 17 00:00:00 2001 From: Dhevenddra Date: Fri, 31 Jul 2026 14:58:31 +0530 Subject: [PATCH] fix: match audio extensions case-insensitively Path.suffix preserves case while the extension sets are lowercase, so .WAV and .MP3 files never matched. All three call sites fail quietly: - utils/file.py backs list_files, which builds the training set in data/datasets/vocoder.py, so uppercase audio was dropped from the dataset without a warning. - test.py dispatches inference on the suffix and ends in `else: continue`, so those files were skipped with no message and no output. - scripts/random_copy.py carried the same comparison. Lowercase before comparing, and in test.py read the lowered suffix in both branches so the two comparisons cannot drift apart. --- fish_vocoder/test.py | 5 +++-- fish_vocoder/utils/file.py | 6 +++++- scripts/random_copy.py | 6 +++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/fish_vocoder/test.py b/fish_vocoder/test.py index 821ef1d..9d0791b 100644 --- a/fish_vocoder/test.py +++ b/fish_vocoder/test.py @@ -50,7 +50,8 @@ def main(cfg: DictConfig): audios = list(input_path.rglob("*")) for audio_path in audios: - if audio_path.suffix in [".wav", ".flac", ".mp3"]: + suffix = audio_path.suffix.lower() + if suffix in [".wav", ".flac", ".mp3"]: gt_y, sr = librosa.load(audio_path, sr=cfg.model.sampling_rate, mono=False) # If mono, add a channel dimension @@ -70,7 +71,7 @@ def main(cfg: DictConfig): logger.info(f"gt_y shape: {gt_y.shape}, lengths: {lengths}") inputs = model.mel_transforms.input(gt_y.squeeze(1)) - elif audio_path.suffix in [".pt", ".pth"]: + elif suffix in [".pt", ".pth"]: input_mels = torch.load(audio_path, map_location=model.device).to( torch.float32 ) diff --git a/fish_vocoder/utils/file.py b/fish_vocoder/utils/file.py index dc650d1..9830fcb 100644 --- a/fish_vocoder/utils/file.py +++ b/fish_vocoder/utils/file.py @@ -52,7 +52,11 @@ def list_files( ) if extensions is not None: - files = [f for f in files if f.suffix in extensions] + # Match case-insensitively. Recorders, phones and camera firmware write + # .WAV/.MP3, and Path.suffix preserves that case, so an exact match + # dropped those files from the dataset without a warning. + extensions = {ext.lower() for ext in extensions} + files = [f for f in files if f.suffix.lower() in extensions] if sort: files = sorted(files) diff --git a/scripts/random_copy.py b/scripts/random_copy.py index 258a2bf..9ea19b6 100644 --- a/scripts/random_copy.py +++ b/scripts/random_copy.py @@ -15,7 +15,11 @@ def random_copy(src: Path, dst: Path, num: int, seed: int): src, dst = Path(src), Path(dst) - files = [f for f in src.rglob("*") if f.is_file() and f.suffix in [".wav", ".flac"]] + files = [ + f + for f in src.rglob("*") + if f.is_file() and f.suffix.lower() in [".wav", ".flac"] + ] logger.info(f"Found {len(files)} files in {src}") generator = random.Random(seed)