Skip to contentSkip to navigationSkip to topbar
On this page

Detecting the Dominant Speaker


(warning)

Warning

This documentation is for reference only. We are no longer onboarding new customers to Programmable Video. Existing customers can continue to use the product until December 5, 2026(link takes you to an external page).

We recommend migrating your application to the API provided by our preferred video partner, Zoom. We've prepared this migration guide(link takes you to an external page) to assist you in minimizing any service disruption.

This guide introduces the Dominant Speaker Detection API and provides guidance on how to use it effectively in your Twilio Video applications. The Dominant Speaker API is only available in Group Rooms.

In a multi-party video application, the dominant speaker is the Participant sharing the loudest audio track in the Room. The Dominant Speaker Detection API sends events to your application every time the dominant speaker changes. Developers can use those events to improve the end user's experience by bringing into focus the speakers published video tracks.


API Usage

api-usage page anchor

The Room.dominantSpeaker property (Android(link takes you to an external page), (iOS(link takes you to an external page), JavaScript(link takes you to an external page)) represents the RemoteParticipant with the loudest RemoteAudioTrack. Whenever the Dominant Speaker changes, the Room emits a dominantSpeakerChanged event.

Note: dominantSpeakerChanged events are emitted in Group Rooms with 2 or more Participants.

Enabling Dominant Speaker Detection

enabling-dominant-speaker-detection page anchor

The Dominant Speaker API is disabled by default, and is requested at connect time. The following table illustrates the currently supported platforms:

Twilio Video SDKDominant Speaker API support (Group Rooms)
AndroidYes (v4.3.0+)
iOSYes (v2.8.0+)
JavaScriptYes (v1.14.0+)

Android

android page anchor

When building ConnectOptions, set the property enableDominantSpeaker to true.

1
ConnectOptions connectOptions =
2
new ConnectOptions.Builder(token)
3
.roomName(roomName)
4
.enableDominantSpeaker(true)
5
.build();
6
Room room = Video.connect(context, connectOptions, roomListener);

Implement Room.Listener#onDominantSpeakerChanged(@NonNull Room room, @Nullable RemoteParticipant remoteParticipant)(link takes you to an external page) in order to respond to speaker events.

1
@Override
2
void onDominantSpeakerChanged(
3
@NonNull Room room, @Nullable RemoteParticipant remoteParticipant) {
4
// Handle dominant speaker change
5
}

When building TVIConnectOptions, set the property isDominantSpeakerEnabled to true.

1
let connectOptions = ConnectOptions(token: accessToken) { (builder) in
2
// Enable Dominant Speaker functionality
3
builder.isDominantSpeakerEnabled = true
4
5
if let localAudioTrack = self.localAudioTrack {
6
builder.audioTracks = [localAudioTrack]
7
}
8
builder.roomName = "my-conference-room"
9
}
10
11
room = TwilioVideoSDK.connect(options: connectOptions, delegate: self)

Implement -[TVIRoomDelegate room:dominantSpeakerDidChange:](link takes you to an external page) in order to respond to speaker events.

1
// MARK: TVIRoomDelegate
2
func dominantSpeakerDidChange(room: Room, participant: RemoteParticipant?) {
3
var identity = "N/A"
4
5
if let participant = participant {
6
identity = participant.identity
7
}
8
9
print("Dominant Speaker Changed: \(identity)")
10
}

In the connect method, set the property dominantSpeaker to true to enable the Dominant Speaker API and to start receiving dominantSpeakerChanged events.

1
var Video = require('twilio-video');
2
var token = getAccessToken();
3
4
// Connect with custom names for LocalAudioTrack and LocalVideoTrack
5
Video.connect(token, {
6
name: 'my-conference-room'
7
audio: { name: 'microphone' },
8
video: { name: 'camera' },
9
dominantSpeaker: true
10
}).then(function(room) {
11
room.on('dominantSpeakerChanged', participant => {
12
console.log('The new dominant speaker in the Room is:', participant);
13
});
14
});

  • At present it is not possible to detect when a PSTN participant is the dominant speaker. A PSTN participant is one who dials a Twilio phone number and is connected to a Room using the Connect TwiML verb