Skip to content

feat: detect speech natively for local audio tracks - #490

Merged
devopvoid merged 5 commits into
mainfrom
feat/local-audio-tap
Oct 31, 2026
Merged

devopvoid merged 5 commits into
mainfrom
feat/local-audio-tap

Conversation

@devopvoid

@devopvoid devopvoid commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

LocalAudio.onVoiceActivity tells when this side starts and stops speaking. The voice activity detector runs in native code and only the changes reach Java; VoiceActivityConfig sets the threshold and the hangover.

WebRTC's microphone source hands no audio to sinks, so every AudioProcessing now carries a capture post-processor that detects speech in its output, after echo cancellation, noise suppression and gain control: PeerConnectionFactory.addVoiceActivityListener. Pushed audio, and remote tracks, take a native sink instead: AudioTrack.addVoiceActivityListener. The audio is mixed down to mono and resampled to 16 kHz first, so any rate works, 44.1 kHz included.

WebRTC's LocalAudioSource ignores AddSink, so VoiceActivityExample attached to a microphone track hears nothing. Say which tracks feed a sink, and point to AudioRecorder for the microphone.
LocalAudio.onAudio hands pushed audio as pushed, and a microphone's audio after audio processing, as the senders send it. Every AudioProcessing now carries a capture post-processor that hands its output to a sink, through AudioProcessing.setCapturedAudioSink and PeerConnectionFactory.setCapturedAudioSink.
The VAD guide, VoiceActivityExample and the audio processing guide show the processed microphone audio of the client API and of PeerConnectionFactory.setCapturedAudioSink.
# Conflicts:
#	docs/tools/audio/voice-activity-detector.md
#	webrtc-examples/src/main/java/dev/onvoid/webrtc/examples/VoiceActivityExample.java
Replaces LocalAudio.onAudio with onVoiceActivity: the native VAD runs in the audio processing tap (microphone) or in a track sink (pushed audio), and only speech start and end reach Java. VoiceActivityConfig sets threshold and hangover.
@devopvoid devopvoid changed the title feat: the audio a local track sends, in the client API feat: detect speech natively for local audio tracks Oct 31, 2026
@devopvoid
devopvoid merged commit 25b2f2c into main Oct 31, 2026
25 checks passed
@devopvoid
devopvoid deleted the feat/local-audio-tap branch October 31, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant