Repository navigation
fix(moonshine_asr): reject audio beyond the position-embedding limit instead of crashing - #662
Conversation
|
@Faazil-jpg I don't think this is the right solution. I forgot to wire the audio chunker into the model, so for tiny it will fail about 81.9 seconds. I will update this PR directly. |
f4919f5 to
b2ed457
Compare
b2ed457 to
75bc55e
Compare
|
Thanks for the context — makes sense. I dug into it after your comment: I can see Canary's session.cpp already uses engine::audio::plan_audio_chunks()/AudioChunkMode to split long input before hitting the encoder, and Moonshine's streaming-chunk path is a different thing entirely (incremental input buffering, not pre-encoder splitting), so that's exactly the gap. Happy to take a pass at wiring it in the same way Canary does if that's useful, or I'll leave it to you since you're already on it — whichever's less friction for you. |
|
@Faazil-jpg It should work now. |
|
@Faazil-jpg Thanks for offering to help! Sorry, I missed your message earlier. I also added a more explict error message. The Silero VAD model currently used by the chunker requires 16 kHz audio. For 48 kHz or other sample rates, VAD cannot be used, and a different chunking mode should be selected. |
Resolves #661
Fixes the
GGML_ASSERT(i01 >= 0 && i01 < ne01)crash reported in #661 when runningmoonshine_asron audio longer than ~82s (16kHz), in both offline and streaming mode.Root cause: the encoder adds a learned absolute position embedding (
model.decoder.pos_emb.weight, a real GGUF weight tensor with a fixed row count ofmax_position_embeddings= 4096 for the released tiny/small/medium checkpoints) to its per-frame memory output before decoder cross-attention. Nothing validated that the actual number of post-conv encoder memory frames fit within that table before theggml_get_rowslookup ran, so long-enough audio read out of bounds and hit the GGML assertion instead of a clean error.This is a genuine fixed-context-length limit of the released checkpoints (the embedding table itself has only 4096 rows) rather than a fixable off-by-one, so this PR turns the crash into an actionable
runtime_errorraised before the expensive encoder-transformer/decoder work runs, rather than attempting internal auto-chunking (a larger change out of scope here).Verified:
No existing test in
tests/referencesmoonshine_asr, so none needed updating.