fix: match audio and video extensions case-insensitively - #39
Open
Dhevenddra wants to merge 1 commit into
Open
Conversation
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.
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
list_files()filters by extension with an exact match:Path.suffixpreserves case, andAUDIO_EXTENSIONSandVIDEO_EXTENSIONSare all lowercase. A file namedRECORDING.WAVtherefore never matches, andlist_filesdrops 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-labandtranscribe.The failure is silent. The files are simply absent from the count, so a run over a directory of
.WAVfiles reports success having processed nothing.Reproduced against
mainwith six files in one directory:After the change all five audio files are found and
ignored.txtis still excluded.Fix
Compare case-insensitively.
list_filesalso lowercases the incoming set, so a caller passing{".WAV"}behaves the same way.cli/merge_lab.pyandcli/transcribe.pyre-filter onAUDIO_EXTENSIONSafter callinglist_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
Pathobjects 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-onlyandcodespellare all clean.