Skip to content

fix: match audio extensions case-insensitively - #11

Open
Dhevenddra wants to merge 1 commit into
fishaudio:mainfrom
Dhevenddra:fix-case-insensitive-extensions
Open

fix: match audio extensions case-insensitively#11
Dhevenddra wants to merge 1 commit into
fishaudio:mainfrom
Dhevenddra:fix-case-insensitive-extensions

Conversation

@Dhevenddra

Copy link
Copy Markdown

Problem

Extensions are compared against Path.suffix, which preserves case, while the extension sets are lowercase. Files written as .WAV or .MP3 therefore never match. Recorders, phones and camera firmware produce those routinely.

Three places are affected, and all three fail quietly:

utils/file.py:55 feeds list_files, which data/datasets/vocoder.py:25 uses to build the training set. Uppercase audio is dropped from the dataset with no warning, so a run trains on a smaller corpus than the user thinks.

Reproduced against main on a directory of six files:

on disk : ['B.WAV', 'E.MP3', 'a.wav', 'c.Flac', 'd.mp3', 'skip.txt']
found   : ['a.wav', 'd.mp3']
missing : ['B.WAV', 'c.Flac', 'E.MP3']

After the change all five audio files are found and skip.txt is still excluded.

test.py:53 and :73 dispatch inference on the suffix, and the trailing else: continue means an uppercase file is skipped without a message. Pointing test.py at a directory of .WAV files writes no output and reports no error.

scripts/random_copy.py:18 carries the same comparison.

Fix

Lowercase before comparing. list_files also lowercases the incoming set, so a caller passing {".WAV"} behaves the same. In test.py the suffix is lowered once and both branches read it, which keeps the two comparisons from drifting apart later.

Nothing else changes: sorting, recursion, the extension sets and the returned Path objects keep their behaviour, and each filename keeps its original case.

Verification

The repository has no test suite, so rather than introduce a framework I verified with the directory reproduction above, run before and after the change.

black --check, isort --check-only and ruff are clean on the changed files. Two pre-existing findings are unrelated and unchanged by this PR: ruff E721 in modules/generators/refinegan.py:107, and codespell flagging fro in modules/losses/stft.py:55, which is the Frobenius norm argument.

Related

The same comparison exists in fishaudio/audio-preprocess, where I opened PR #39 for it, and in fish-speech's DAC inference entry point (PR #1313). The list_files helper looks to be shared lineage across the three repos.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant