> ## Documentation Index
> Fetch the complete documentation index at: https://developer.audioshake.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Diarization

> Label who spoke when in a recording, with speaker count and confidence scores

Run diarization to get who-spoke-when segments, the number of speakers, and confidence scores — without separating the audio. It returns the same diarization JSON that [Multi-Speaker Separation](/multi-speaker-separation) includes alongside its stems, so use `multi_voice` instead when you also need the per-speaker audio.

## Create a Task

<CodeGroup>
  ```python diarization.py theme={null}
  import requests

  API_KEY = "your_api_key"
  HEADERS = {"Content-Type": "application/json", "x-api-key": API_KEY}

  response = requests.post(
      "https://api.audioshake.ai/tasks",
      headers=HEADERS,
      json={
          "assetId": "your_asset_id",
          "targets": [
              {"model": "diarization", "formats": ["json"]}
          ]
      }
  )

  task_id = response.json()["id"]
  print(f"Task created: {task_id}")
  ```

  ```javascript diarization.js theme={null}
  const API_KEY = "your_api_key";
  const headers = { "Content-Type": "application/json", "x-api-key": API_KEY };

  const createRes = await fetch("https://api.audioshake.ai/tasks", {
    method: "POST",
    headers,
    body: JSON.stringify({
      assetId: "your_asset_id",
      targets: [
        { model: "diarization", formats: ["json"] }
      ]
    })
  });

  const { id: taskId } = await createRes.json();
  console.log(`Task created: ${taskId}`);
  ```

  ```bash curl theme={null}
  curl -X POST "https://api.audioshake.ai/tasks" \
    -H "Content-Type: application/json" \
    -H "x-api-key: $AUDIOSHAKE_API_KEY" \
    -d '{
      "assetId": "your_asset_id",
      "targets": [
        { "model": "diarization", "formats": ["json"] }
      ]
    }'
  ```
</CodeGroup>

[Check Task status](/check-task-status) to monitor progress and download results, or use [webhooks](/api-reference/tasks/webhooks) to be notified when the target completes.

## Output

The task returns one `diarization` JSON output:

```json diarization.json theme={null}
{
  "results": {
    "diarization": {
      "segments": [
        { "speaker": "SPEAKER_01", "start": 0.213, "end": 4.673 },
        { "speaker": "SPEAKER_00", "start": 4.813, "end": 12.793 },
        { "speaker": "SPEAKER_01", "start": 11.913, "end": 19.993 }
      ],
      "num_speakers": 2,
      "scores": {
        "scores_per_frame": {
          "assignment_confidence": { "resolution": 0.02, "score": [0.883, 0.946, "..."] }
        },
        "scores": {
          "assignment_confidence": 0.946
        }
      }
    }
  }
}
```

All fields are relative to `results.diarization`:

* `segments` — one entry per speech segment, with `speaker` and `start`/`end` in seconds. The timeline is overlap-aware: segments from different speakers can overlap when people talk at once.
* `num_speakers` — number of distinct speakers detected.
* `scores` — `assignment_confidence` in \[0, 1], per-frame at 20 ms resolution and for the whole file: how confident the model is that speech is attributed to the right speaker.

## Use cases

* Attribute transcripts to speakers without paying for audio separation
* Count speakers and measure talk time in meetings, calls, and interviews
* Pre-screen recordings to decide which need full Multi-Speaker Separation

<CardGroup cols={2}>
  <Card title="Multi-Speaker Separation" icon="users" href="/multi-speaker-separation">
    Get per-speaker audio stems along with the same diarization output.
  </Card>

  <Card title="Speech Recovery" icon="waveform-lines" href="/speech-recovery">
    Denoise and de-reverb speech recordings.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.