Speakers (Diarization & Speaker ID)¶
Overview¶
Who spoke when, who said what, and whether a voice belongs to a known person. Each question has its own model:
Capability |
Model |
Answers |
|---|---|---|
|
who spoke when: speaker-labelled time segments |
|
|
who said what: turns with text, plus a voice per speaker, tied to people you have enrolled |
|
|
is this the same person: a voice embedding to enroll and compare by cosine similarity |
Use the timeline alone when you only need turns. Use multi-speaker transcription when you also want the words and the speakers tied to enrolled people. Use speaker embeddings to enroll a person, to verify a voice, or to gate the voice agent on a known speaker.
For a transcript with speaker labels from the ASR engine (its speakers
option), see Speakers in ASR (Speech-to-Text). This page covers the
underlying models and their raw APIs.
All three take the same audio as the rest of the SDK: 16 kHz mono float
samples in [-1, 1]. Resample before calling; nothing downstream will do it
for you.
Supported models¶
Model type |
HF Repo |
Notes |
|---|---|---|
|
|
Streaming Sortformer. NPU only: Snapdragon 8 Gen 2, 8 Gen 3, 8 Elite, 8 Elite Gen 5; no CPU bundle |
|
none ( |
Composite: owns no engines, wires a diarization, an embedding, and optionally a VAD and an ASR model you started yourself |
|
|
ReDimNet2 B0. 192-d L2-normalized embedding from a 2 s / 16 kHz window; NPU on Snapdragon 8 Gen 2, 8 Gen 3, 8 Elite and 8 Elite Gen 5, CPU elsewhere |
See Device notes for how each one picks its compute device.
Speaker timeline¶
nemotron-diarization is a streaming Sortformer. Segments close as they
end, so during a conversation you get committed turns rather than waiting
for it to finish.
TheStageAI.start_model(
model_name = "diar",
engines_path = "TheStageAI/Nemotron-3-Diarization",
)
// One-shot over a recording.
val rows = TheStageAI.infer(
model_name = "diar",
input_json = mapOf("audio" to samples), // 16 kHz mono
)
Streaming uses the push contract from Streaming input in
Streaming: open with infer_stream, push with
stream_append, close with stream_finish. Chunks carry segments,
and kind says what they are:
|
|
|---|---|
|
segments that just closed — final, they will not change |
|
segments still running — will be superseded |
|
every segment of the whole stream |
|
nothing; the session was abandoned |
Render committed as settled text and partial as provisional; a partial
is replaced by the next one, and eventually by a committed.
TheStageAI.infer_stream(
model_name = "diar",
input_json = mapOf("stream_id" to "turn-1"),
).collect { chunk ->
chunk.segments?.forEach { seg ->
println("${seg.speaker}: ${seg.start}..${seg.end}")
}
}
Speaker labels (SPEAKER_00, SPEAKER_01, …) are stable across the
recording but arbitrary — they are not identities. For identities, see
Multi-speaker transcription.
Multi-speaker transcription¶
nemotron-multispeaker is a composite: it owns no engines and is assembled
from models you started yourself, so they keep their own lifetimes and can be
shared with the rest of your app.
// Start the components first — each is an ordinary model.
TheStageAI.start_model(model_name = "diar", engines_path = "TheStageAI/Nemotron-3-Diarization")
TheStageAI.start_model(model_name = "embed", engines_path = "TheStageAI/speaker-id-v2")
TheStageAI.start_model(model_name = "vad", engines_path = "TheStageAI/silero-vad")
TheStageAI.start_model(model_name = "asr", engines_path = "TheStageAI/thewhisper-large-v3-turbo")
// Then wire them.
TheStageAI.start_model(
model_name = "meeting",
model_type = "nemotron-multispeaker",
engines_path = "", // composites have no bundle
config = mapOf(
"diarization" to "diar",
"embedding" to "embed",
"vad" to "vad", // required for streaming
"asr" to "asr", // omit for turns without text
),
)
Flutter:
await TheStageFlutterSDK.start_nemotron_multispeaker(
model_name: 'meeting',
diarization_model: 'diar',
embedding_model: 'embed',
vad_model: 'vad',
asr_model: 'asr',
);
diarization and embedding are required. Without asr you get turns
and no text; without vad the streaming path is unavailable.
Enrolling speakers¶
Pass embeddings of people you already know and their turns come back with
identity set instead of an anonymous label. Vectors must come from the
same embedder the pipeline runs — a vector from another model is
meaningless here. To produce them, see
Speaker embeddings and verification.
val rows = TheStageAI.infer(
model_name = "meeting",
input_json = mapOf(
"audio" to samples,
"enrolled" to listOf(
mapOf("id" to "Ada", "vector" to ada_embedding),
),
),
)
To render a turn, show its identity when known and the anonymous label
otherwise: turn.identity ?: turn.speaker in Kotlin; in Dart,
SpeakerTurn.displayName does exactly that.
Streaming chunk kinds¶
|
Carries |
|---|---|
|
|
|
tentative turns of the open utterance (opt in with |
|
|
|
a new speaker-cache epoch began |
|
every speaker, plus the profile |
|
the session was abandoned |
identity_update is the one worth handling deliberately. Speakers are
decided incrementally, so two labels can later turn out to be one person — the
chunk’s delta names the merge ("SPEAKER_04->SPEAKER_01"). An app that
has already drawn those turns should relabel them rather than leave two
speakers on screen that are the same person.
Timeline and multi-speaker inputs / outputs¶
Field |
Type |
Notes |
|---|---|---|
input |
float list |
16 kHz mono, |
input |
list |
multispeaker only; |
input |
String |
streaming only; identifies the session |
output |
list |
|
output |
list |
multispeaker; a segment plus its |
output |
list |
multispeaker; speaker + embedding + identity |
output |
map |
per-stage timings, diagnostic only |
Speaker embeddings and verification¶
speaker-id (ReDimNet2 B0, TheStageAI/speaker-id-v2) maps a
2 s / 16 kHz mono window to a 192-d, L2-normalized embedding; two
utterances are compared by cosine similarity. Use it to enroll a person
(audio → embedding) and to verify a voice (audio + reference embedding →
similarity).
Quick start¶
Kotlin — via the singleton (auto-downloads the bundle):
import ai.thestage.qlip.TheStageAI
TheStageAI.registerContext(context)
TheStageAI.initialize(api_token = "your-api-token")
TheStageAI.start_model(
model_name = "speaker_id",
model_type = "speaker-id",
engines_path = "TheStageAI/speaker-id-v2",
)
// Enroll: audio only → embedding.
val enroll = TheStageAI.infer(
model_name = "speaker_id",
input_json = mapOf(
"audio" to mapOf(
"data" to pcm_16k_mono, // FloatArray, samples in [-1, 1]
"shape" to listOf(pcm_16k_mono.size),
"dtype" to "float32",
)
)
)
val embedding = enroll[0]["embedding"] as List<Double> // 192 floats
// Verify: audio + a reference embedding → also "similarity".
val check = TheStageAI.infer(
model_name = "speaker_id",
input_json = mapOf(
"audio" to mapOf("data" to probe_pcm_16k_mono),
"embedding" to mapOf("data" to embedding),
)
)
val similarity = check[0]["similarity"] as Double // cosine
Flutter — JSON path:
import 'package:thestage_android_sdk/thestage_android_sdk.dart';
await TheStageFlutterSDK.initialize(api_token: 'your-api-token');
await TheStageFlutterSDK.start_model(
model_name: 'speaker_id',
model_type: 'speaker-id',
engines_path: 'TheStageAI/speaker-id-v2',
);
// Enroll → embedding.
final enroll = await TheStageFlutterSDK.infer(
model_name: 'speaker_id',
input_json: {
'audio': {'data': pcm16k, 'shape': [pcm16k.length], 'dtype': 'float32'},
},
);
final embedding = (enroll[0]['embedding'] as List).cast<double>();
// Verify → similarity.
final check = await TheStageFlutterSDK.infer(
model_name: 'speaker_id',
input_json: {
'audio': {'data': probePcm16k},
'embedding': {'data': embedding},
},
);
final similarity = check[0]['similarity'] as double;
Audio contract¶
Item |
Value |
|---|---|
Sample rate |
16 000 Hz mono float ( |
Window |
2.0 s (32 000 samples). Any length in — longer keeps the trailing 2 s, shorter is repeated to fill the window |
Output dim |
192, L2-normalized |
Compute device |
NPU on the supported chips, CPU elsewhere (see Device notes) |
Embedding inputs / outputs¶
Inputs and outputs of the JSON infer call:
Key |
Direction |
Type |
Notes |
|---|---|---|---|
|
in |
|
Required |
|
in |
|
Optional reference; when present, the response also carries
|
|
out |
|
The probe embedding |
|
out |
|
Cosine vs the reference (present only when a reference was supplied) |
The response is a single-element list. The caller chooses the accept
threshold; for raw same-speaker acceptance a value around 0.4 is a
reasonable starting point — tune it against your own audio and false-
accept tolerance. (The Voice-agent speaker gating uses a stricter
default of 0.75.)
Voice-agent speaker gating¶
The voice agent can require speaker verification before it wakes, so it only responds to an enrolled speaker. Configure it on the agent:
Field |
Type |
Default |
Description |
|---|---|---|---|
|
String |
|
Set to |
|
|
|
The reference embedding the incoming speaker is scored against |
|
Double |
|
Cosine at/above which the speaker is accepted |
Enroll (or re-enroll) the reference embedding on a running agent:
// embedding: the List<Double> from an earlier speaker_id infer() call.
agent.enroll_speaker(embedding.toDoubleArray()) // null clears enrollment
await agent.enroll_speaker(embedding: embedding); // List<double>?
vad_speaker_id_wake_word layers speaker verification on top of the
wake-word gate: the agent leaves sleeping only when the wake word
fires and the trailing speech scores at/above
speaker_similarity_threshold against the enrolled embedding. See
Voice Agent for the full agent surface.
Device notes¶
nemotron-diarization. The diarization frontend (STFT, mel, projection) is
native and runs per 80 ms frame. The model itself runs on the NPU; its bundles
are published for Snapdragon 8 Gen 2, 8 Gen 3, 8 Elite and 8 Elite Gen 5, and
there is no CPU bundle, so on other chips start_model fails — see
Model Management. Because nemotron-multispeaker requires
a diarization model, it is limited to the same chips.
speaker-id. Runs on the NPU on Snapdragon 8 Gen 2, 8 Gen 3, 8 Elite and
8 Elite Gen 5, and on the CPU on every other phone. With device unset, a
start on a supported chip whose NPU build does not open falls back to the CPU
build on its own. Both builds return vectors in the same format.
The bundles are published and pinned by the SDK; rebuilding or re-exporting them is not part of the public workflow. Contact TheStage if you need a variant that is not published.
Agent Checklist¶
Audio is always 16 kHz mono float in
[-1, 1]; resample before calling.Timeline:
TheStageAI/Nemotron-3-Diarization; labels are stable but anonymous; NPU-only chips.Who said what:
nemotron-multispeakerwithengines_path = "";diarizationandembeddingrequired,vadfor streaming,asrfor text; handleidentity_updatemerges.For a transcript with speakers through the ASR engine, use its
speakersoption (ASR (Speech-to-Text), Speakers).Speaker ID: model type
speaker-id; common handlespeaker_id; repoTheStageAI/speaker-id-v2; 2 s window; 192-d output.Verify = audio + reference
embedding→similarity; you pick the threshold.Leave
deviceunset forspeaker-id: NPU on supported chips, CPU elsewhere.