instructor icon indicating copy to clipboard operation
instructor copied to clipboard

Audio MIME aliases fail for data URIs and remote sources

Open emme1t opened this issue 2 months ago • 1 comments

Description

Audio.from_path() accepts the WAV MIME alias audio/x-wav and canonicalizes it to audio/wav. Audio.from_base64(), Audio.from_url(), and Audio.from_gs_url() reject that same alias before constructing an audio object. An automatically detected WAV data URI can consequently remain plain text in a message instead of becoming an audio content block.

The existing AAC alias audio/vnd.dlna.adts has the same inconsistency. Its dotted subtype also fails Audio.is_base64() recognition.

Reproduction

from instructor.v2.core.multimodal import Audio

Audio.from_base64("data:audio/x-wav;base64,UklGRg==")
# ValueError: Unsupported audio format: audio/x-wav

Audio.is_base64("data:audio/vnd.dlna.adts;base64,AA==")
# False

The MIME check fails before audio bytes are inspected. The WAV case also reproduces with a complete PCM WAV generated by Python's wave module.

Expected behavior

All audio constructors apply the same existing WAV/AAC alias mapping, preserve the supplied bytes and source, and recognize the dotted AAC subtype in data URIs. OpenAI's existing restriction to WAV and MP3 remains in effect after normalization.

Environment and validation

  • Current main: e12f8b49203b0c1f253d27c1e709d0a09b9fc5a8.
  • Python 3.12.13 on Windows.
  • Offline regression tests use a real PCM WAV and real Google GenAI content objects; no model requests are needed.
  • Four regression cases fail on the existing implementation; two canonical-format/unsupported-format controls pass.

emme1t avatar Sep 22 '26 10:09 emme1t

Verified WAV and AAC aliases for data URIs, HTTP downloads and Google Cloud Storage inputs. Fixed on main in https://github.com/567-labs/instructor/pull/2909.

jxnl-oai avatar Nov 05 '26 18:11 jxnl-oai