Overview
Speaker diarization identifies individual speakers in your audio and labels each segment of the transcript with the speaker. When enabled, the transcript is returned as a list of utterances, where each utterance represents an uninterrupted segment of speech from a single speaker. Accuracy improves the more each speaker talks as the model accumulates embedding context. For best results, each speaker should have at least 30 seconds of continuous speech.Quickstart
- Python
- Python SDK
- JavaScript
- JavaScript SDK
To enable Speaker Diarization, set
speaker_labels to True in the POST request body:Configuration
You can constrain the number of speakers withspeakers_expected, or with min_speakers_expected/max_speakers_expected. These are hard boundaries on the number of speaker labels, not hints: max_speakers_expected is a strict cap — if more people speak than that, the additional speakers are merged into existing labels — and min_speakers_expected is a strict floor.
- If you know the exact number of speakers, set
speakers_expected. - If you have a rough idea, use
min_speakers_expectedandmax_speakers_expectedto set a range. Setmax_speakers_expecteda little higher than the number of speakers you expect so the model has room to identify any additional speakers. Setting it too high can cause the model to over-split and return more speaker labels than are actually present.
| Key | Type | Default | Description |
|---|---|---|---|
speaker_labels | boolean | false | Enable Speaker Diarization. |
speakers_expected | number | — | Set the exact number of speakers. |
speaker_options | object | — | Set range of possible speakers. |
speaker_options.min_speakers_expected | number | — | A hard lower limit on the number of speaker labels. The model won’t return fewer speakers than this. |
speaker_options.max_speakers_expected | number | 0–2 minutes: — 2–10 minutes: 10 speakers 10+ minutes: 30 speakers | A hard upper limit on the number of speaker labels. If more people speak than this, the additional speakers are merged into existing labels. Give the model a little headroom above the number of speakers you expect; setting it too high can cause over-splitting and return more speakers than are actually present. |
Only set
speakers_expected when you are certain of the exact speaker count. If you’re unsure, use min_speakers_expected and max_speakers_expected to describe a range instead — providing an incorrect exact count can negatively affect diarization accuracy.Reading the response
When diarization is enabled, the transcript includes anutterances array in place of a single text block. Each object in the array represents one uninterrupted segment of speech from a single speaker.
utterances array contains objects with the following fields:
Each object in the
words array contains the following fields:
Identify speakers by name
Speaker Diarization assigns generic labels like “Speaker A” and “Speaker B” to each speaker. If you want to replace these labels with actual names or roles, you can use Speaker Identification to transform your transcript. Before Speaker Identification:- Python
- JavaScript
maxLines=30
Best practices for accurate diarization
Follow these tips to get the best results from Speaker Diarization:- Ensure sufficient speech per speaker. Each speaker should speak for at least 30 seconds uninterrupted. The model may struggle to create separate clusters for speakers who only contribute short phrases like “Yeah”, “Right”, or “Sounds good”.
- Minimize cross-talk. Overlapping speech between speakers can reduce diarization accuracy. Where possible, ensure speakers take turns.
- Reduce background noise. Background noise, echoes, or playback of recorded audio during a conversation can interfere with speaker separation.
- Use
speaker_optionsinstead ofspeakers_expectedwhen uncertain. Only usespeakers_expectedwhen you are confident about the exact number of speakers. If this number is incorrect, the model may produce random splits of single-speaker segments or merge multiple speakers into one. It’s generally recommended to usemin_speakers_expectedand setmax_speakers_expectedslightly higher (e.g.,min_speakers_expected+ 2) to allow flexibility. - Avoid setting
max_speakers_expectedtoo high. Setting the maximum too high may reduce accuracy, causing sentences from the same speaker to be split across multiple speaker labels. - Be aware of speaker similarity. If speakers sound similar, the model may have difficulty distinguishing between them.