Speaker embedding¶
On-device speaker embedding for enrollment and cosine verification.
Public type: SpeakerEmbedding (family thestage_speaker_embedding).
Produces a 192-d L2-normalized vector from 16 kHz mono PCM. Default compute device is CPU.
Basic usage¶
Swift (singleton JSON path — same shape as Flutter):
try await TheStageAI.shared.start_model(
model_name: "speaker_id",
engines_path: "TheStageAI/redimnet2",
model_type: "thestage_speaker_embedding"
)
let out = try TheStageAI.shared.infer(
model_name: "speaker_id",
input_json: ["audio": pcm_16k_mono]
)
// out[0]["embedding"] → [Double] length 192
let check = try TheStageAI.shared.infer(
model_name: "speaker_id",
input_json: [
"audio": pcm_16k_mono,
"embedding": reference_embedding,
]
)
// check[0]["similarity"] → Double (cosine)
Flutter:
await TheStageFlutterSDK.start_model(
model_name: 'speaker_id',
engines_path: 'TheStageAI/redimnet2',
);
final enrolled = await TheStageFlutterSDK.infer(
model_name: 'speaker_id',
input_json: {'audio': pcm16k},
);
Audio contract¶
Item |
Value |
|---|---|
Sample rate |
16 000 Hz mono Float / |
Window |
2.0 s (32 000 samples) — pad/trim trailing |
Output dim |
192, L2-normalized |
Device default |
|
Caller chooses the accept threshold (voice agent default is 0.75).
Voice agent¶
Set speaker_id on the agent config and call enroll_speaker.
See Voice Agent.
Agent checklist¶
Family id:
thestage_speaker_embedding; common handle:speaker_id.Always 16 kHz mono; 2 s window.
Verify = audio + reference embedding →
similarity.