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

# Diarization

> Work out who spoke when

Diarization segments a recording by speaker. It answers "who spoke when", not "what did they
say"; pair it with [transcription](/react-native/stt/transcribe) for both.

```ts theme={null}
import { AudioInputs } from '@runanywhere/core'

const result = await RunAnywhere.diarization.diarize(AudioInputs.file(path))
```

## Options

| Field               | Meaning                                                        |
| ------------------- | -------------------------------------------------------------- |
| `threshold`         | How different two voices must be to count as separate speakers |
| `minimumDurationMs` | Ignore segments shorter than this                              |
| `mergeGapMs`        | Join two segments from one speaker separated by less than this |

`mergeGapMs` is the one to tune. Natural speech has pauses inside a turn, and without merging
you get one speaker fragmented into a dozen segments.

## Diarization inside transcription

For a transcript labelled by speaker rather than a separate segment list, ask the STT namespace
instead:

```ts theme={null}
const transcription = await RunAnywhere.stt.transcribe(audio, {
  diarization: true,
  maxSpeakers: 2,
})
```

Use the STT route when you want a readable transcript. Use the diarization namespace when you
want timing, for example to drive a speaker timeline or to split a recording into per-speaker
files.

## Knowing the speaker count helps

`maxSpeakers` on the STT path, and a sensible `threshold` here, both improve accuracy a lot
when you know how many people are in the room. Diarization over-segments when left to guess.

React Native has no streaming diarizer. Diarize a completed recording, or use the STT path with
`diarization: true` for live labelling.
