> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nyra-labs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nyra-labs.com/_mcp/server.

# Forced alignment

`POST /v1/audio/alignments` takes an audio file and its transcript and returns
when every word was said, the timing of every sound inside it, and how well
each word fits the audio. Fillers, laughter, breaths and cut-off words get
timestamps of their own. **English only.** \$0.25 per audio hour.

#### Get a key and top up

The same key and prepaid wallet as transcription. See
[Quickstart](/quickstart) and [Billing](/billing).

#### Align

Send the file and the transcript as `multipart/form-data`.

```bash
curl https://api.nyra-labs.com/v1/audio/alignments \
  -H "Authorization: Bearer $NYRA_API_KEY" \
  -F "file=@clip.wav" \
  -F "model=nyra-forced-aligner-en" \
  -F "language=en" \
  -F "text=Just change our p- but that's [laughter] just change our priorities a little bit"
```

## Parameters

| Field      |          | Notes                                                                                                      |
| ---------- | -------- | ---------------------------------------------------------------------------------------------------------- |
| `file`     | required | One audio file, up to **25 MB** and **1 hour**, in any [accepted format](/transcription#accepted-formats). |
| `text`     | required | What is said in the recording, written as below. Up to 200 000 characters.                                 |
| `model`    | required | `nyra-forced-aligner-en`. Anything else answers `400 model_not_found`.                                     |
| `language` | optional | `en`, the default. Any other value answers `400 unsupported_language`.                                     |

## Transcript conventions

The aligner places exactly what the transcript contains, so **write what you
hear**, not a cleaned-up version:

| Write                | For                                 | Example                        |
| -------------------- | ----------------------------------- | ------------------------------ |
| Every word as spoken | repetitions, false starts, restarts | `we we need to, to reschedule` |
| `[UH]`, `[UM]`       | filled pauses                       | `so [UM] I think`              |
| `[tag]`              | vocal sound events, see below       | `that's [laughter] just`       |
| A trailing hyphen    | words broken off mid-way            | `the th- Thursday meeting`     |
| Words, not digits    | numbers, dates, times, emails       | `March third at nine thirty`   |

Casing and punctuation are ignored, and tags match in any casing (`[Laughter]`,
`[um]`). [CrisperWhisper](/transcription)'s `verbatim.text` already follows these
conventions: send it as `text` unchanged. The Quickstart has the
[two calls, transcribe then align](/quickstart#transcribe-then-align-two-calls),
in curl and Python.

### Vocal sound events

Each tag is a unit of the model like a phone, so the event gets its own word
in the response, with `type: "sound"`:

| Tag                | Phone in the response |
| ------------------ | --------------------- |
| `[laughter]`       | `LAU`                 |
| `[breath]`         | `BRE`                 |
| `[cough]`          | `COF`                 |
| `[sigh]`           | `SGH`                 |
| `[sniff]`          | `SNF`                 |
| `[lipsmack]`       | `LPS`                 |
| `[throatclearing]` | `TCL`                 |
| `[yawn]`           | `YWN`                 |
| `[sneeze]`         | `SNZ`                 |
| `[crying]`         | `CRY`                 |
| `[scream]`         | `SCR`                 |
| `[fart]`           | `FRT`                 |
| `[noise]`          | `NSN`                 |

`[UH]` and `[UM]` come back with `type: "filler"` and the phones `FUH` and
`FUM`. A tag the model does not know, such as `[music]`, is left out of the
alignment and listed in `skipped`.

### When the transcript is wrong

The transcript is taken as true. A word that was said but is missing from it is
absorbed by its neighbours; a word in it that was never said is squeezed into a
few frames. Both shift the boundaries around them and both show up as low
[`confidence`](#confidence). A transcript of a different recording fails with
`400 alignment_failed` or `alignment_too_complex`, and is not charged.

## Response

```json
{
  "duration": 4.98,
  "language": "en",
  "words": [
    {
      "word": "our", "start": 0.54, "end": 0.93, "type": "word", "confidence": 0.796,
      "phones": [
        { "phone": "AW", "start": 0.54, "end": 0.71 },
        { "phone": "AX", "start": 0.71, "end": 0.93 }
      ]
    },
    {
      "word": "p-", "start": 0.93, "end": 1.09, "type": "cutoff", "confidence": 0.931,
      "phones": [{ "phone": "P", "start": 0.93, "end": 1.09 }]
    },
    {
      "word": "[laughter]", "start": 2.5, "end": 2.85, "type": "sound", "confidence": 0.873,
      "phones": [{ "phone": "LAU", "start": 2.5, "end": 2.85 }]
    }
  ],
  "skipped": [],
  "usage": { "type": "duration", "seconds": 5 }
}
```

| Field               | Meaning                                                                                                                 |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `words`             | Every transcript token in order, as you wrote it (punctuation kept), except those in `skipped`.                         |
| `start`, `end`      | Seconds from the start of the recording, 10 ms resolution. Words never overlap; gaps between them are silence.          |
| `type`              | `word`, `filler` (`[UH]`, `[UM]`), `sound` (a vocal sound event) or `cutoff` (a fragment ending in `-`).                |
| `phones`            | The word's sounds in order, covering exactly its span: ARPAbet phones (`TH`, `ER`, `AY`, ...) or the event units above. |
| `confidence`        | 0 to 1: how well the audio under the word fits it. See below.                                                           |
| `skipped`           | Tokens that could not be aligned: unknown tags and tokens without a pronunciation.                                      |
| `duration`, `usage` | Decoded audio duration in seconds, and the billed whole seconds.                                                        |

### Confidence

This is a different number from the `confidence` on
[transcription words](/transcription#word-confidence): that one is the speech
model's certainty about **what** was said, this one is how well the audio
fits the word **where** it was placed. A word can be high on one and low on
the other, and checking both catches more than either alone.

Per 10 ms frame, the aligner compares the sound it placed there with the
best-fitting sound of the whole model; `confidence` is that fit averaged over
the word, from 1 (perfect) down to 0.

| `confidence` | Typically                                                                       |
| ------------ | ------------------------------------------------------------------------------- |
| 0.8 to 1     | The word is there and its timing can be trusted. Two thirds of correct words.   |
| 0.5 to 0.8   | Fast, reduced or mumbled speech. Almost always fine.                            |
| 0.3 to 0.5   | Worth a look if exact timing matters.                                           |
| below 0.3    | The transcript is likely wrong here: misheard, or next to speech it leaves out. |

* **Look at runs.** One low word is usually a short or reduced one. Several in
  a row mean the transcript and the audio disagree there, typically speech
  that was not transcribed.
* **Cut-offs and very short words score lower** by nature. Judge them against
  their own kind, not against a fixed threshold.
* **It ranks, it does not correct.** The timestamps are the same either way;
  use it to filter words or to send stretches to review.

## Python

```python
import os
import requests

with open("clip.wav", "rb") as audio:
    response = requests.post(
        "https://api.nyra-labs.com/v1/audio/alignments",
        headers={"Authorization": f"Bearer {os.environ['NYRA_API_KEY']}"},
        files={"file": ("clip.wav", audio, "audio/wav")},
        data={
            "model": "nyra-forced-aligner-en",
            "language": "en",
            "text": "so we [UH] we need to reschedule the th- Thursday meeting [laughter]",
        },
        timeout=600,
    )

response.raise_for_status()
for word in response.json()["words"]:
    flag = "  <- check" if word["confidence"] < 0.5 else ""
    print(f"{word['start']:6.2f} {word['end']:6.2f} {word['word']}{flag}")
```

## Pricing and limits

**\$0.25 per audio hour**, billed per second: \$0.000069 per second, with the
duration rounded up to a whole second per request. Funds are held before the
audio is aligned and only what was used is charged; a request that fails is
not charged. See [Billing](/billing).

The limits are those of [transcription](/transcription#limits): 25 MB per upload
and one hour of audio per request, so send long recordings compressed (an hour
of 48 kbps MP3 is about 22 MB). An hour aligns in one request with no drift:
the last minute is as accurate as the first. `Idempotency-Key` works as
[for transcription](/transcription#retries-and-idempotency), bound to the model,
the language and the exact transcript.

## Errors

The envelope and the general errors are those of
[transcription](/transcription#errors). Specific to alignment:

| Status | `code`                       | When                                                                                                                                 |
| ------ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `400`  | `missing_required_parameter` | `text` (or `file`, `model`) was not sent or is empty.                                                                                |
| `400`  | `unsupported_language`       | `language` is not `en`.                                                                                                              |
| `400`  | `model_not_found`            | `model` is not `nyra-forced-aligner-en`.                                                                                             |
| `400`  | `alignment_failed`           | The transcript cannot be placed in the audio: it belongs to another recording, or it is longer than the audio can hold. Not charged. |
| `400`  | `alignment_too_complex`      | The same on a long recording, found out after a wider search. Not charged.                                                           |
| `503`  | `capacity_exceeded`          | The aligner is busy. Retry after `retry-after`. Not charged.                                                                         |