Documentation
¶
Overview ¶
Package audiovalidate provides lightweight audio-file integrity checks that run before expensive transcription or disk-write operations.
The checks are intentionally minimal: they guard against obviously-corrupt files (e.g. 4096-byte all-zero uploads) rather than full format validation. False-negatives (corrupt files that pass) are handled downstream; these guards exist to short-circuit the infinite-retry loop caused by files that will never successfully decode.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotM4A = errors.New("audio file missing ftyp box at offset 4 (not a valid m4a/mp4)")
ErrNotM4A is returned when the data does not carry the ISO Base Media File Format "ftyp" box at offset 4, which is required for m4a/mp4 audio.
var ErrTooShort = errors.New("audio file too short to be a valid container")
ErrTooShort is returned when the provided data is shorter than minAudioBytes.
Functions ¶
func CheckAudioBytes ¶
CheckAudioBytes enforces the minimum-length guard only, without any container-format check. Use this for non-m4a audio formats (mp3, wav, etc.) where byte[4:8] does not carry a known magic value.
Returns ErrTooShort when len(data) < 8, nil otherwise.
func CheckM4A ¶
CheckM4A validates the leading bytes of an m4a/mp4 audio payload.
Checks performed (in order):
- Minimum length: len(data) >= 8. Shorter data is rejected with ErrTooShort.
- ftyp magic: bytes[4:8] == "ftyp". Files that lack this box are rejected with ErrNotM4A.
All other file formats (mp3, wav, etc.) should use CheckAudioBytes instead, which only enforces the minimum-length guard.
Returns nil when the data passes both checks.
Types ¶
This section is empty.