fix(hooks): allow VAD streamInsert/streamStop during streaming - #1196
Merged
Conversation
useVAD exposed stream, streamInsert, and streamStop all through runForward, which rejects calls while isGenerating === true. While stream() was in flight, every streamInsert(chunk) rejected with "model is currently generating" — making the streaming API unusable. Add a runSideChannel primitive to useModuleFactory that only checks isReady, never isGenerating. Streaming hooks now have two regimes: - Gated (runForward): forward, stream — one at a time. - Side-channel (runSideChannel): streamInsert, streamStop — allowed during a running stream. Migrate useVAD.streamInsert/streamStop onto runSideChannel. Future streaming hooks (and the planned TTS/STT migration onto useModuleFactory) can use the same primitive. Fixes #1173
benITo47
approved these changes
May 29, 2026
benITo47
left a comment
Contributor
There was a problem hiding this comment.
Tested on iOS - fix works ✅
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.
Description
useVADexposedstream,streamInsert, andstreamStopall throughuseModuleFactory.runForward, which rejects calls whileisGenerating === true. Oncestream()was in flight, everystreamInsert(chunk)rejected with "model is currently generating" — making the streaming API unusable in practice.Add a
runSideChannelprimitive touseModuleFactorythat only checksisReady(neverisGeneratingand never flips it). Streaming hooks now have two regimes:runForward):forward,stream— one at a time.runSideChannel):streamInsert,streamStop— allowed during a running stream.useVAD.streamInsert/streamStopnow userunSideChannel.useTextToSpeechanduseSpeechToTextaren't affected (they avoiduseModuleFactoryentirely for their side-channel methods); they're candidates for a follow-up migration onto the new primitive.Introduces a breaking change?
Type of change
Tested on
Testing instructions
End-to-end on the
apps/speechVoice Activity Detection screen:SPEAKING/SILENTevents appear in the log as expected. Without it (git checkout HEAD~1 -- packages/react-native-executorch/src/hooks/{useModuleFactory.ts,natural_language_processing/useVAD.ts}and reload Metro):streamInsertrejects on every 100 ms audio chunk and no SPEAKING transition fires and error occurs.Related issues
Fixes #1173