Skip to content
Tutorials12 min read

Speaker Diarization Annotation

Mark who spoke when on an audio waveform, or correct WhisperX speaker labels turn by turn, with Potato configs for both tasks and the segment JSON they export.

Potato Team

To annotate speaker diarization in Potato, annotators mark who speaks when on the audio waveform. Annotators either draw each speaker turn and label the turn with a speaker, or correct the turns a diarizer such as pyannote, NeMo, or WhisperX already produced. This tutorial builds a waveform task for marking turns from scratch, imports an RTTM diarization for annotators to correct on the waveform, and sets up a transcript review task for checking speaker labels turn by turn. The post ends with the segment JSON and the RTTM files the waveform tasks export. For the full audio scheme reference, see the source documentation.

Speaker diarization and diarizer output

Speaker diarization splits a recording into stretches that belong to one speaker and gives each stretch a speaker identifier. It answers "who spoke when", and it comes up wherever a recording has more than one voice in it, from meeting minutes and call center analytics to podcast production, research interviews, and legal recordings.

Potato is where people check and correct a diarization. The first pass comes from a diarization system such as pyannote, WhisperX, or a cloud transcription API. From version 2.9, potato transcripts --transcribe --diarize produces that first pass on your own machine, with sherpa-onnx for diarization and WhisperX or faster-whisper for transcription. Potato reads diarized transcripts as WhisperX JSON, CTM, Praat TextGrid, ELAN EAF, SRT, and WebVTT, and the transcript formats reference lists the rest. From version 2.14.0, Potato also imports RTTM, the diarization format pyannote and NeMo write, as turns to correct on the waveform.

Marking speaker turns on the waveform

With no upstream output to correct, annotators draw the turns themselves on a waveform. The scheme is audio_annotation in label mode, and item_properties.text_key names the field holding the audio URL, which is how Potato finds the media for each item.

yaml
annotation_task_name: "Speaker Diarization"
task_dir: "."
 
data_files:
  - "data/conversations.json"
 
item_properties:
  id_key: id
  text_key: audio_url
 
output_annotation_dir: "annotation_output/"
export_annotation_format: "jsonl"
 
annotation_schemes:
  - annotation_type: audio_annotation
    name: speakers
    description: "Mark each stretch of speech and label who is speaking"
    mode: label
    zoom_enabled: true
    playback_rate_control: true
    min_segments: 1
    label_requirement:
      required: true
    labels:
      - name: Speaker 1
        color: "#FF6B6B"
        key_value: "1"
      - name: Speaker 2
        color: "#4ECDC4"
        key_value: "2"
      - name: Speaker 3
        color: "#45B7D1"
        key_value: "3"
      - name: Overlap
        color: "#FFEAA7"
        key_value: "4"
      - name: Silence
        color: "#9CA3AF"
        key_value: "5"
 
user_config:
  allow_all_users: true

The Overlap and Silence labels are there to keep the timeline complete. Without a label for crosstalk, an annotator has to decide which of two simultaneous speakers owns the region, and two annotators will decide differently on the same second of audio. Without one for silence, a gap in the timeline is ambiguous between "nobody spoke" and "nobody got to it yet".

min_segments takes effect only alongside label_requirement.required: true. With both set, Next stays blocked until the annotator has marked at least one segment and labeled every segment they marked, and the message says which of the two is missing.

Drawing a segment

The annotator has three ways to create one, and the right one depends on how precise the boundary has to be. Right-click and drag on the zoomed waveform draws a segment directly, and the view auto-scrolls when the drag reaches an edge, so a turn longer than the visible window still takes one gesture. Right-click and drag on the overview draws a coarse segment anywhere in the recording without navigating there first. The [ and ] keys set the boundaries at the playhead and Enter creates the segment, which is the fastest route when the annotator is listening straight through. Left-click keeps its usual job of moving the playhead in all three cases, so navigation and drawing never collide.

Audio annotation is paced by the transport controls, so give annotators the shortcuts on day one:

KeyAction
SpacePlay or pause
Left / RightSeek 5 seconds back or forward
Shift+Left / Shift+RightSeek 30 seconds
[ / ]Set segment start / end at the playhead
EnterCreate the segment from the selection
Delete / BackspaceDelete the selected segment
1-9Select the label at that position in the list
+ / - / 0Zoom in, out, or fit the waveform to the view

Questions on each turn

A speaker label alone will not carry speech acts, speaker roles, or a per-turn quality judgment. Setting mode: both keeps the labels and attaches a set of questions to each segment, which the annotator answers in the segment panel after selecting a region:

yaml
annotation_schemes:
  - annotation_type: audio_annotation
    name: turns
    description: "Mark each speaker turn and describe it"
    mode: both
    labels:
      - name: Moderator
        color: "#EF4444"
        key_value: "1"
      - name: Participant 1
        color: "#3B82F6"
        key_value: "2"
      - name: Participant 2
        color: "#10B981"
        key_value: "3"
      - name: Overlap
        color: "#FCD34D"
        key_value: "4"
    segment_schemes:
      - annotation_type: radio
        name: speech_type
        description: "What kind of turn is this?"
        labels: ["Statement", "Question", "Response", "Interruption", "Backchannel"]
      - annotation_type: radio
        name: speaker_confidence
        description: "How sure are you about the speaker?"
        labels: ["Certain", "Probable", "Guess"]

Two limits come with segment questions. Keyboard shortcuts are not bound inside them, because a segment's fields only exist while that segment is selected and a global key would fire against whichever segment happened to be open, so these answers are given by clicking. label_requirement is not enforced on a sub-scheme either, since marking one required would block Next on a question the annotator may not have opened, so completeness on those fields is checked in analysis instead.

A speaker_confidence field of this kind is worth the extra click on hard audio. It separates the turns an annotator was sure about from the ones they guessed, which is the difference between a disagreement that means your label set is wrong and one that means the recording is bad.

Correcting an RTTM diarization

From Potato 2.14.0, potato import -f rttm turns RTTM files from pyannote or NeMo into a waveform task with each diarizer turn drawn as a pre-annotation. Put the RTTM files and the recordings in one folder, with each recording named after the RTTM file id (meet000.wav for meet000), and import the folder:

bash
potato import -f rttm -i diarization/ -o interviews \
  --speaker-map "SPEAKER_00=Interviewer,SPEAKER_01=Guest"

The importer makes one item per recording and writes a config with an audio_annotation scheme named speakers, whose labels are the speakers. Annotators move a turn's edges, change a turn's speaker, delete a turn of noise, and draw any turn the diarizer missed, with the controls and shortcuts above. --speaker-map renames speakers in every recording, so use the map only when a name means the same person in every file. A diarizer numbers speakers within each file, and SPEAKER_00 in two recordings can be two different people. --media-dir names the folder holding the recordings when the recordings are not beside the RTTM files, and --rttm-scheme tiered puts the turns on a tiered_annotation speaker tier for a study that transcribes turn by turn afterwards.

The corrected turns can train a speaker diarization model of your own. Potato's diarization trainer fine-tunes a speech encoder, WavLM by default, on the turns annotators corrected. With writeback set, the model's predicted turns appear as editable pre-labels on the held-out recordings, and with include_unlabeled: true on the recordings nobody has corrected yet. Train Speech and Audio Models on Your Annotations walks through the import, the training run, and the held-out diarization error rate.

Reviewing a diarized transcript

When a diarization system has already segmented and transcribed the recording, redrawing its boundaries on a waveform wastes the work. The audio_dialogue display renders a diarized transcript as speaker bubbles synced to the audio, each with a play button for that turn alone, so annotators read and listen rather than drawing. It reads WhisperX-style diarized JSON, where each segment carries a start, an end, text, and a speaker, along with subtitle and caption formats, and turns with no speaker render as unassigned for the annotator to fill in.

audio_dialogue is a display rather than an annotation type, so it goes under instance_display.fields and the annotation schemes stay separate. A turn_level scheme bound to that field puts the same question on every turn:

yaml
annotation_task_name: "Diarization Review"
task_dir: "."
 
data_files:
  - "data/interviews.json"
 
item_properties:
  id_key: id
  text_key: conversation
 
output_annotation_dir: "annotation_output/"
export_annotation_format: "jsonl"
 
instance_display:
  fields:
    - key: conversation
      type: audio_dialogue
      label: "Transcript"
      display_options:
        audio_key: audio
        turns_key: turns
        show_timestamps: true
        speakers:
          - id: interviewer
            name: "Interviewer"
            color: "#7c3aed"
            side: left
          - id: participant
            name: "Participant"
            color: "#059669"
            side: right
 
annotation_schemes:
  - annotation_type: radio
    name: speaker_correct
    description: "Is the speaker label on this turn right?"
    labels: ["Correct", "Wrong speaker", "Two speakers in one turn"]
    turn_level: true
    turn_binding:
      field: conversation
 
  - annotation_type: radio
    name: recording_quality
    description: "Overall recording quality"
    labels:
      - "Excellent, all speakers clear"
      - "Good, most speech understandable"
      - "Fair, some difficulty"
      - "Poor, significant problems"
 
user_config:
  allow_all_users: true

The speakers roster fixes a color and a side for each known speaker, so a mislabeled turn shows up as a bubble on the wrong side of the transcript before the annotator has read a word of it. Clicking a turn's speaker name reassigns it, including to a speaker who was not in the roster. A stable turn_id on each turn is what per-turn answers are stored against, so keep those identifiers fixed if you re-ingest the transcripts after fixing anything upstream. Reassigned speakers are saved under conversation_speakers, keyed by the same turn_id.

Building the data file from a folder of ASR output is one command:

bash
potato transcripts ./whisper_out --media-dir ./audio -o data/interviews.json

The command writes each item as an id plus a conversation field holding the audio path and the turns. The config above names conversation as its text_key to match.

Multiple annotators on the same audio

Speaker boundaries are where annotators disagree most, and one pass over a recording gives you nothing to compare. num_annotators_per_item sets the coverage target for the project:

yaml
num_annotators_per_item: 3

Three annotators on a pilot subset is enough to show whether the label set holds up before the full recording set goes out. The agreement report for time segments compares each pair of annotators by matching their segments on temporal overlap. For choosing the size of that subset and reading the result, see the quality control guide.

What the output file holds

In the JSONL export, each annotator's segments for an item sit in labels under the scheme name. The value is one JSON string in a _data field. Decoded, the string lists each segment with its own identifier, its boundaries in seconds, its label, and any answers from the segment questions:

json
{
  "turns": {
    "segments": [
      {
        "id": "segment_1",
        "start_time": 0.0,
        "end_time": 5.2,
        "label": "Moderator",
        "annotations": {
          "speech_type": "Statement",
          "speaker_confidence": "Certain"
        }
      },
      {
        "id": "segment_2",
        "start_time": 5.2,
        "end_time": 12.8,
        "label": "Participant 1",
        "annotations": {
          "speech_type": "Response",
          "speaker_confidence": "Certain"
        }
      }
    ]
  }
}

Boundaries are stored in seconds rather than samples, so the same file can be lined up against a transcript from any automatic speech recognition (ASR) system without a conversion step. Each segment keeps its own identifier as well, which is what lets a second annotator's pass be compared against the first segment by segment instead of turn count by turn count.

From version 2.14.0, the segments export writes one JSONL row per segment and one RTTM file per annotator under rttm/. RTTM is the input that pyannote.metrics, dscore, and md-eval score a diarization against, so a diarization corrected in Potato goes back into those scoring tools unchanged:

bash
python -m potato.export --config config.yaml --format segments --output ./export/

Long recordings

Waveform rendering is the part that breaks on hour-long audio. Installing the BBC's audiowaveform tool lets Potato compute waveforms on the server rather than in the annotator's browser, which is the difference between a task that opens immediately and one that stalls on every item:

bash
brew install audiowaveform          # macOS
sudo apt-get install audiowaveform  # Ubuntu/Debian

Without it, Potato falls back to generating the waveform in the browser, which suits files under about 30 minutes. Pre-computing the next few instances keeps annotators from waiting between items:

yaml
audio_annotation:
  waveform_cache_dir: waveform_cache/
  waveform_look_ahead: 3
  waveform_cache_max_size: 50

Frequently asked questions

What file formats does a speaker diarization annotation project use?

A Potato diarization project takes WAV, MP3, or OGG audio and reads diarized transcripts as WhisperX JSON, CTM, Praat TextGrid, ELAN EAF, SRT, or WebVTT. The configs in this post export annotations as JSONL, with segment boundaries in seconds. From version 2.14.0, potato import -f rttm reads RTTM files as speaker turns to correct, and the segments export writes each annotator's turns back out as RTTM. A tiered_annotation scheme with one tier per speaker can export Praat TextGrid and ELAN EAF instead.

How do I check whether diarization annotations are offset?

Play turns on their own and listen to where each one starts and ends. In the review task, the play button on each audio_dialogue bubble plays only that turn's audio. Boundaries are shifted against the recording when a turn opens mid-word or ends on the next speaker's first words. For two annotators' segments of the same recording, the agreement report gives the mean temporal overlap of matched segments. Boundaries that drift apart lower that value.

Next steps