-
Notifications
You must be signed in to change notification settings - Fork 134
Always run VAD when enabled. #627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Was set to only run when requested, but it makes the signal useless. TODO: Figure out a good API to request stuff run locally.
WalkthroughThis pull request adds AudioContext closure guards across four audio-related files to prevent AudioWorkletNode instantiation when the context state is "closed". The changes are applied to captions, encoder, speaking, and source modules. Additionally, in the encoder module, the asynchronous race pattern for loading the CaptureWorklet is replaced with a direct await of Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
js/hang/src/publish/audio/captions.ts (1)
105-106: Clarify the comment wording.The comment states "Ensure the context is running" but the code checks if the context is "closed". An AudioContext can be in "suspended", "running", or "closed" states. A suspended context would pass this check but wouldn't be "running". Consider updating the comment to accurately reflect what's being checked.
Apply this diff to improve comment accuracy:
- // Ensure the context is running before creating the worklet + // Skip worklet creation if the context is already closed if (ctx.state === "closed") return;js/hang/src/watch/audio/source.ts (1)
122-123: Clarify the comment wording.The comment states "Ensure the context is running" but the code checks if the context is "closed". Consider updating the comment to accurately reflect the check being performed.
Apply this diff to improve comment accuracy:
- // Ensure the context is running before creating the worklet + // Skip worklet creation if the context is already closed if (context.state === "closed") return;js/hang/src/publish/audio/encoder.ts (1)
107-108: Add a comment for consistency.The guard at Line 108 is correct and follows the same pattern as the other files in this PR (captions.ts, source.ts, speaking.ts). However, those files include a comment explaining the guard, while this one doesn't. Consider adding a comment for consistency.
Apply this diff to add a comment:
await context.audioWorklet.addModule(CaptureWorklet); + // Skip worklet creation if the context is already closed if (context.state === "closed") return;js/hang/src/publish/audio/speaking.ts (1)
77-78: Clarify the comment wording.The comment states "Ensure the context is running" but the code checks if the context is "closed". Consider updating the comment to accurately reflect the check being performed.
Apply this diff to improve comment accuracy:
- // Ensure the context is running before creating the worklet + // Skip worklet creation if the context is already closed if (ctx.state === "closed") return;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
js/hang/src/publish/audio/captions.ts(1 hunks)js/hang/src/publish/audio/encoder.ts(1 hunks)js/hang/src/publish/audio/speaking.ts(1 hunks)js/hang/src/watch/audio/source.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{rs,js}/hang/**
📄 CodeRabbit inference engine (CLAUDE.md)
{rs,js}/hang/**: All media-specific logic (encoding/streaming, codec handling) must live in the hang layer.
Keep the hang layer generic: expose primitives (e.g., access to individual frames) and avoid application/UI-specific code.
Files:
js/hang/src/watch/audio/source.tsjs/hang/src/publish/audio/captions.tsjs/hang/src/publish/audio/speaking.tsjs/hang/src/publish/audio/encoder.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Check
It was changed to on-demand, but that breaks the public signals.
In the future we should only run VAD when there's a subscription or the signal is actively being used.
Summary by CodeRabbit