Documentation
¶
Overview ¶
Package audio provides audio container/codec helpers for AI providers.
The motivating use case is Gemini transcription: Gemini's audio inputs require WAV/MP3/AIFF/AAC/OGG/FLAC, but browser MediaRecorder defaults to WebM/Opus. This package converts WebM/Opus into 16-bit PCM WAV using pure-Go decoders — no ffmpeg or other system dependency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsWebMContentType ¶
IsWebMContentType reports whether the MIME type is WebM audio. Both "audio/webm" and "audio/webm; codecs=opus" return true.
func WebMOpusToWAV ¶
WebMOpusToWAV decodes a WebM/Opus file into 16-bit PCM WAV bytes.
The output is mono or stereo at 48 kHz (Opus's native decode rate), regardless of the original encoder's hint. Pre-skip samples declared in the OpusHead are discarded to avoid the encoder's startup padding.
The function reads the entire WebM document into memory; callers should enforce their own size limits before invoking it.
Types ¶
This section is empty.