Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions docs/tools/audio/voice-activity-detector.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ peer.onTrack(track -> {
});
```

The client API has no audio subscription on a local track. To detect speech at
the microphone, attach the adapter as an `AudioTrackSink` to an `AudioTrack` of
the native API:
An `AudioTrack` of the native API takes the adapter as an `AudioTrackSink`, as
long as the track's source hands its audio to sinks. A remote track and a track
over a `CustomAudioSource` do:

```java
VoiceActivityExample sink = new VoiceActivityExample(speech -> {
Expand All @@ -165,6 +165,11 @@ finally {
}
```

A microphone track does not: WebRTC passes captured audio from the audio device
module straight to the senders, and the source of the track hands nothing to
sinks. An [`AudioRecorder`](/tools/audio/audio-recorder) captures a microphone
on its own, apart from any peer connection.

The adapter invokes the consumer on the thread that delivers the audio: a thread
of the `onAudio` subscription, or the audio callback thread of a sink. Keep work
there short. A subscription that falls behind loses the oldest audio beyond its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
/**
* With the client API, subscribe it to a remote track with
* {@link RemoteAudio#onAudio(Consumer)}, then close the {@link Subscription}
* before close(). An AudioTrack of the native API, such as a microphone's,
* takes it with addSink(), then removeSink() before close().
* before close(). An AudioTrack of the native API takes it with addSink(),
* then removeSink() before close(), if its source hands audio to sinks: that
* of a remote track or a CustomAudioSource does, a microphone's does not.
* Buffers arbitrary chunk lengths into 10 ms frames and converts interleaved
* signed 16-bit PCM to 16 kHz mono, including input at 44.1 kHz. The consumer runs
* on the thread that delivers the audio and should return promptly. It receives raw
Expand Down
Loading