Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Detecting the Dominant Speaker


(warning)

Warning

This page 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, 2024(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.


_10
ConnectOptions connectOptions =
_10
new ConnectOptions.Builder(token)
_10
.roomName(roomName)
_10
.enableDominantSpeaker(true)
_10
.build();
_10
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.


_10
@Override
_10
void onDominantSpeakerChanged(
_10
@NonNull Room room, @Nullable RemoteParticipant remoteParticipant) {
_10
// Handle dominant speaker change
_10
}

When building TVIConnectOptions, set the property isDominantSpeakerEnabled to true.


_11
let connectOptions = ConnectOptions(token: accessToken) { (builder) in
_11
// Enable Dominant Speaker functionality
_11
builder.isDominantSpeakerEnabled = true
_11
_11
if let localAudioTrack = self.localAudioTrack {
_11
builder.audioTracks = [localAudioTrack]
_11
}
_11
builder.roomName = "my-conference-room"
_11
}
_11
_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.


_10
// MARK: TVIRoomDelegate
_10
func dominantSpeakerDidChange(room: Room, participant: RemoteParticipant?) {
_10
var identity = "N/A"
_10
_10
if let participant = participant {
_10
identity = participant.identity
_10
}
_10
_10
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.


_14
var Video = require('twilio-video');
_14
var token = getAccessToken();
_14
_14
// Connect with custom names for LocalAudioTrack and LocalVideoTrack
_14
Video.connect(token, {
_14
name: 'my-conference-room'
_14
audio: { name: 'microphone' },
_14
video: { name: 'camera' },
_14
dominantSpeaker: true
_14
}).then(function(room) {
_14
room.on('dominantSpeakerChanged', participant => {
_14
console.log('The new dominant speaker in the Room is:', participant);
_14
});
_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

Rate this page: