Repository navigation
Conversation
Add an opt-in hook to the streaming ASR managers (StreamingUnifiedAsrManager, StreamingNemotronAsrManager): `setEncoderOutputCallback` receives each encoder prediction's raw outputs plus the step's local frame range and global frame origin (global = origin + local), so consumers can read intermediate features — e.g. layer taps from an encoder re-exported with extra declared outputs — without a second encoder pass. Motivation: on-device turn-decision models read encoder-layer taps per frame. Today that means running a second encoder chain beside the ASR (a ~390 MB duplicate in our app); this hook lets one pass serve both transcription and feature consumers. Unset (default) behavior is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
An opt-in raw encoder-outputs callback for the streaming ASR managers (
StreamingUnifiedAsrManagerandStreamingNemotronAsrManager):Default behavior is unchanged — the hook is nil unless set.
Why
On-device turn-decision models (end-of-utterance, barge-in, backchannel timing) read encoder-layer taps per frame alongside transcription. Without access to the encoder outputs, apps must run a second encoder chain just to extract features — in our app that is a ~390 MB duplicate model and a redundant encoder pass per frame.
This hook lets one encoder pass serve both the RNNT decoder and feature consumers. Combined with an encoder export that declares extra outputs (e.g. an intermediate
tap_l12), it enables sharing the ASR's own encoder for downstream features with zero duplicated compute.Details
([String: MLMultiArray], Range<Int>, Int) -> Void.StreamingNemotronAsrManagertrackstapFrameOriginacross chunks and resets it with the caches inresetStates().plan.bufferStartFrameas the origin.Happy to adjust naming/shape (e.g. a delegate protocol instead of a closure) to match project conventions.