Skip to content

fix: match audio and video extensions case-insensitively - #39

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

fix: match audio and video extensions case-insensitively#39
Dhevenddra wants to merge 1 commit into
fishaudio:mainfrom
Dhevenddra:fix-uppercase-extensions

Conversation

@Dhevenddra

Copy link
Copy Markdown

Problem

list_files() filters by extension with an exact match:

files = [f for f in files if f.suffix in extensions]

Path.suffix preserves case, and AUDIO_EXTENSIONS and VIDEO_EXTENSIONS are all lowercase. A file named RECORDING.WAV therefore never matches, and list_files drops it without a warning.

Recorders, field recorders, phones and camera firmware routinely write uppercase extensions, so this hits real datasets. Every command that scans a directory is affected, because they all pass those lowercase sets: length, loudness-norm, merge-short, resample, separate-audio, slice-audio, convert-to-wav, merge-lab and transcribe.

The failure is silent. The files are simply absent from the count, so a run over a directory of .WAV files reports success having processed nothing.

Reproduced against main with six files in one directory:

files on disk : ['Mixed.Wav', 'UPPER.MP3', 'UPPER.WAV', 'ignored.txt', 'lower.mp3', 'lower.wav']
list_files got: ['lower.mp3', 'lower.wav']

MISSING (silently skipped): ['Mixed.Wav', 'UPPER.MP3', 'UPPER.WAV']

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

Fix

Compare case-insensitively. list_files also lowercases the incoming set, so a caller passing {".WAV"} behaves the same way.

cli/merge_lab.py and cli/transcribe.py re-filter on AUDIO_EXTENSIONS after calling list_files, so they carried the same comparison and are updated too.

Notes

Only the extension comparison changed. Sorting, recursion, the video/audio sets and the returned Path objects keep their existing behaviour, and the original case of each filename is untouched.

The repository has no test suite or test dependency, so rather than introduce one I verified with the directory reproduction above, run before and after the change. Happy to add tests if you would like a framework brought in.

black --check, isort --check-only and codespell are all clean.

Path.suffix preserves case while AUDIO_EXTENSIONS and VIDEO_EXTENSIONS are
lowercase, so list_files dropped RECORDING.WAV and similar without a warning.
Recorders, phones and camera firmware commonly write uppercase extensions, so
a directory of them scanned as empty and every command reported success having
processed nothing.

merge_lab and transcribe re-filter on AUDIO_EXTENSIONS after calling
list_files, so they carried the same comparison.
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