Skip to content

feat(asr): opt-in long-audio chunking to stay under the encoder frame limit - #21

Merged
achetronic merged 2 commits into
masterfrom
fix/chunk-long-audio
Jul 1, 2026
Merged

feat(asr): opt-in long-audio chunking to stay under the encoder frame limit#21
achetronic merged 2 commits into
masterfrom
fix/chunk-long-audio

Conversation

@achetronic

@achetronic achetronic commented Jul 1, 2026

Copy link
Copy Markdown
Owner

The encoder crashes on audio over ~400s: its positional-encoding table is [1,9999,1024] centred at 5000, so past 5000 encoder frames the relative-position slice goes out of range and self_attn/Add fails on a broadcast mismatch. Same root cause as #14 and #18.

Features

  • New -long-audio flag (default off). Off: audio over the limit is rejected with a clear error and a log warning. On: the audio is split into overlapping windows and stitched, dropping the overlap so seams are not duplicated.
  • Window sizes in seconds: -chunk-seconds (default 300), -chunk-overlap-seconds (default 15).
  • Audio under the limit is transcribed in one pass, unchanged.

Verification

  • gofmt, go vet, go build, go test -race green. planForAudio/planChunks are pure and table-tested.
  • Live on a real 756s video: off rejects with a warning, on transcribes in full, master crashes on the same file.

Fixes #14
Fixes #18

The exported encoder crashes on audio longer than ~400s: its positional
encoding table is [1,9999,1024] centred at 5000, so past 5000 encoder frames
the relative-position slice goes out of range and self_attn Add fails on a
broadcast mismatch (issues #14, #18).

Split the mel feature sequence into overlapping windows sized in seconds
(-chunk-seconds, default 300; -chunk-overlap-seconds, default 15), run each
through the encoder and TDT decoder, and concatenate the tokens. Each window
decodes in full so the LSTM state and previous-token feedback stay coherent,
but only emits tokens whose timestep falls in its owned region; ownership of
the shared overlap is split at its midpoint so adjacent emit ranges tile the
timeline with no gaps or duplicated speech. Streaming filters by the same
range, so no buffering is needed. Audio under the chunk size takes the single
window path unchanged.

planChunks and the frame math are pure and table-tested (tiling invariant,
deterministic layout, overlap, validation, model-limit rejection). NewTranscriber
rejects chunk sizes that would overrun the model limit.

Fixes #14, #18.
Chunking is now opt-in. With -long-audio off (the default) audio over the
model's single-pass limit is rejected with a clear error and a log warning
pointing at the flag, instead of chunking or crashing. With it on, the
overlapping-window path runs as before.

planForAudio picks the coverage (single window, chunked, or ErrAudioTooLong)
and is pure and table-tested. Chunk-size validation only runs when the mode
is enabled.
@achetronic achetronic changed the title fix(asr): chunk long audio to stay under the encoder frame limit feat(asr): opt-in long-audio chunking to stay under the encoder frame limit Jul 1, 2026
@achetronic achetronic self-assigned this Jul 1, 2026
@achetronic achetronic added the enhancement New feature or request label Jul 1, 2026
@achetronic
achetronic merged commit b556397 into master Jul 1, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Encoder crashes on audio (onnxruntime) Encoder crashes on audio longer than ~3m20s (frozen positional encoding in ONNX export)

1 participant