feat: expose local (microphone) audio level events#162
Merged
Conversation
Co-authored-by: Sahil Suman <sahilsuman933@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: Sahil Suman <sahilsuman933@users.noreply.github.com>
bajajcodes
approved these changes
Jun 2, 2026
mhar-andal
pushed a commit
that referenced
this pull request
Jun 3, 2026
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.
Context
A customer reported a call where the user's audio was never captured, which caused repeated long-pause detections and eventually terminated the call. It was neither a network nor a device-permission issue — the OS-level mic input was effectively silent (wrong device selected / input volume at 0). Daily support recommended using a local audio level observer to detect this and surface a "we can't hear you" prompt.
The Slack thread asked whether local audio level events are exposed by the Vapi web SDK. They were not — the SDK only exposed the assistant's (remote)
volume-level. This PR adds the local side.Changes
In
vapi.ts:startLocalAudioLevelObserver(100)automatically when a call starts (in bothstart()andreconnect()), alongside the existing remote observer.local-volume-levelevent with the user's microphone audio level (a number between 0 and 1).local-audio-level-observer-errorevent when Daily reports alocal-audio-level-observer-error(surfaced via Daily'snonfatal-errorevent, where this error type is actually delivered).getLocalAudioLevel(): number— read the current local mic level on demand (returns0when there is no active call).startLocalAudioLevelObserver(interval?: number): Promise<void>— start/restart the observer (e.g. to change the sampling interval).stopLocalAudioLevelObserver(): voidisLocalAudioLevelObserverRunning(): booleanHow this helps diagnose the reported issue
If
local-volume-levelstays at (or near)0while the user is talking, the microphone isn't capturing audio (wrong input device, OS input muted, etc.) — distinct from a network/SFU problem (wherevolume-level/network events would be the signal) or a hard device error (camera-error/nonfatal-error). Integrators can now show a local "we can't hear you" toast.Testing
Backward compatible — only additive event names, listener types, and methods.