Skip to content

fix(audio): honor extension case and common audio MIME aliases - #2419

Open
Mykola Biron (MykolaBiron) wants to merge 3 commits into
microsoft:mainfrom
MykolaBiron:fix-audio-format-detection
Open

fix(audio): honor extension case and common audio MIME aliases#2419
Mykola Biron (MykolaBiron) wants to merge 3 commits into
microsoft:mainfrom
MykolaBiron:fix-audio-format-detection

Conversation

@MykolaBiron

Copy link
Copy Markdown

AudioConverter.accepts() writes the extension in lowercase and mimetype before the actual comparison happens. However, convert() has compared them verbatim. A file named "recording.WAV" was therefore accepted, emitted its metadata, and then silently skipped transcription.

The accepted mimetype list was also missing common aliases for formats already accepted by extension: audio/wav (far more common than audio/x-wav), audio/mp3, and audio/mp4, audio/m4a, audio/x-m4a. As a result, .m4a support depended entirely on the filename surviving. The alias set matches the one already used for these formats in _cu_converter.py.

Both the accept lists and the format lookup are now derived from a single extension/mimetype map. They cannot drift apart after the fix, and convert() normalizes case the same way accepts() does.

AudioConverter.accepts() lowercases the extension and mimetype before
comparing, but convert() compared them verbatim. A file named
"recording.WAV" was therefore accepted, emitted its metadata, and then
silently skipped transcription.

The accepted mimetype list was also missing common aliases for formats
already accepted by extension: audio/wav (far more common than
audio/x-wav), audio/mp3, and audio/mp4, audio/m4a, audio/x-m4a. As a
result .m4a support depended entirely on the filename surviving. The
alias set matches the one already used for these formats in
_cu_converter.py.

Both the accept lists and the format lookup are now derived from a
single extension/mimetype map so they cannot drift apart, and convert()
normalizes case the same way accepts() does.
@MykolaBiron

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

2 participants