audio

package
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 8 Imported by: 0

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

func IsWebMContentType(contentType string) bool

IsWebMContentType reports whether the MIME type is WebM audio. Both "audio/webm" and "audio/webm; codecs=opus" return true.

func WebMOpusToWAV

func WebMOpusToWAV(input []byte) ([]byte, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL