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)