# Lingolix Pronunciation API (v4)

Scores how well someone pronounced a sentence, word by word and syllable by syllable, with IPA, timing, and tone or pitch accent where the language has them. 22 languages, with tones for Mandarin.

- Endpoint: `POST https://api.lingolix.com/api/pronunciation/v4/check`
- v3 (`/v3/check`) is deprecated and will be switched off on **1 March 2027**: see [Migrating from v3](#migrating-from-v3).
- OpenAPI schema: https://api.lingolix.com/openapi.json (Swagger UI: https://api.lingolix.com/docs)
- API keys: https://lingolix.com/api-portal/dashboard · Plans: https://lingolix.com/api-portal/pricing

## Authentication

Send your API key as a bearer token:

```
Authorization: Bearer lx_your_api_key_here
```

Keep the key server-side. Never ship it in browser or mobile app code. The SDKs read it from `$LINGOLIX_API_KEY`.

## Request

`multipart/form-data` with these fields:

| Field | Required | Description |
|---|---|---|
| `speechdata` | yes | Audio file: WAV, MP3, M4A, OGG, FLAC or WEBM. At most 10 MiB and 60 seconds. |
| `sentence` | no | The text the speaker was supposed to say. Omit it to have the audio transcribed first and scored against that transcript ("just talk" mode). |
| `language_code` | yes | One of the codes below. |

Languages: `bg` Bulgarian, `cs` Czech, `da` Danish, `de` German, `el` Greek, `en` English, `es` Spanish, `fi` Finnish, `fr` French, `hu` Hungarian, `it` Italian, `ja` Japanese, `ko` Korean, `nb` Norwegian (Bokmål), `nl` Dutch, `pl` Polish, `pt` Portuguese, `ru` Russian, `sv` Swedish, `tr` Turkish, `uk` Ukrainian, `zh` Chinese (Mandarin).

Numbers, dates and currency amounts in `sentence` are expanded to words automatically for `en`, `de`, `fr` and `es`; other languages score them as written.

Send compressed audio (MP3, Opus/WebM, AAC). A 10-second utterance is about 320 KB as 16 kHz mono WAV and under 40 KB as 64 kbps Opus, with the same score.

## Examples

```bash
# Known text
curl -X POST "https://api.lingolix.com/api/pronunciation/v4/check" \
  -H "Authorization: Bearer $LINGOLIX_API_KEY" \
  -F "speechdata=@audio.wav" \
  -F "sentence=Guten Morgen" \
  -F "language_code=de"

# Just talk (no sentence)
curl -X POST "https://api.lingolix.com/api/pronunciation/v4/check" \
  -H "Authorization: Bearer $LINGOLIX_API_KEY" \
  -F "speechdata=@audio.wav" \
  -F "language_code=de"
```

Python (`pip install lingolix`):

```python
from lingolix import Lingolix, QuotaExceededError

with Lingolix() as client:  # reads $LINGOLIX_API_KEY; AsyncLingolix is the async twin
    try:
        r = client.check("audio.wav", sentence="Guten Morgen", language="de")
        print(r.overall, r.accuracy, r.fluency, r.speaking_rate)
        for word in r.words:
            print("x" if word.is_error else "ok", word.text, round(word.accuracy, 2))
            for s in word.syllables:
                # zh / ja also have s.reading (pinyin / romaji) and s.prosody (tone / pitch accent)
                print("  ", s.text, s.expected_ipa, "->", s.detected_ipa, round(s.accuracy, 2))
    except QuotaExceededError as e:
        print(f"{e.plan} plan is out of minutes, upgrade at {e.upgrade_url}")
```

TypeScript (`npm install @lingolix/sdk`):

```ts
import { readFile } from "node:fs/promises";
import { Lingolix, QuotaExceededError } from "@lingolix/sdk";

const client = new Lingolix(); // reads $LINGOLIX_API_KEY
const audio = await readFile("audio.wav"); // Blob, Uint8Array or ArrayBuffer

try {
  const r = await client.check({ audio, sentence: "Guten Morgen", language: "de" });
  console.log(r.overall, r.accuracy, r.fluency, r.speaking_rate);
} catch (e) {
  if (e instanceof QuotaExceededError) console.log(`${e.plan} plan is out of minutes`);
}
```

## Response

```json
{
  "text": "Guten Morgen",
  "overall": 0.81,
  "accuracy": 0.78,
  "fluency": 1,
  "completeness": 1,
  "speaking_rate": 4.4,
  "target_speaking_rate": 3,
  "model_version": "2026-11-26",
  "assessable": true,
  "reason": null,
  "words": [
    {
      "text": "Morgen",
      "accuracy": 0.42,
      "completeness": 1,
      "start_ms": 760,
      "end_ms": 1200,
      "char_start": 6,
      "char_end": 12,
      "is_scored": true,
      "is_error": true,
      "hesitation_ms": null,
      "syllables": [
        {
          "text": "Mor",
          "expected_ipa": "mɔʁ",
          "detected_ipa": "ma",
          "accuracy": 0.33,
          "completeness": 0.67,
          "duration_ms": 200,
          "start_ms": 760,
          "end_ms": 960,
          "is_missing": false,
          "is_extra": false,
          "is_scored": true
        }
      ]
    }
  ]
}
```

Show `overall` as the score; `accuracy` and `fluency` explain it, and the words and syllables show where the problems are. All scores are numbers from 0.0 to 1.0. Fields typed `| null` are always present and may be `null`.

### Top level

| Field | Type | Description |
|---|---|---|
| `text` | string | The expected sentence, or the transcript in just-talk mode. |
| `overall` | number | The score to show: accuracy and fluency weighted as human raters weigh them. Always present; equals `accuracy` when `fluency` is null. |
| `accuracy` | number | How well the sounds were pronounced. |
| `fluency` | number \| null | Pace and pauses: full credit from `target_speaking_rate` on, less for each hesitation. `null` when the utterance is too short to time (under 4 syllables). |
| `completeness` | number | Fraction of the expected utterance that was said. |
| `speaking_rate` | number | Syllables (Japanese: morae) per second, from the first syllable's start to the last's. |
| `target_speaking_rate` | number \| null | Pace from which fluency gets full credit, same unit: 60% of a typical native pace. |
| `model_version` | string \| null | Which model and scoring produced the numbers, e.g. `"2026-11-26"`. Changes when an update shifts scores; store it with results. |
| `assessable` | boolean | `false` when the recording can't be graded: silence or noise, or someone saying something else (another text or language). The scores are still computed but mean little: ask for a new recording instead of showing errors. |
| `reason` | `"no_speech"` \| `"noisy"` \| `"mismatch"` \| null | Why `assessable` is `false`: `no_speech` (silence, noise, music), `noisy` (speech buried in noise) or `mismatch` (a different text or language). `null` while `assessable` is `true`. More values may be added; treat unknown ones like `false` `assessable`. |
| `words` | Word[] | Per-word results, below. |

### Word

| Field | Type | Description |
|---|---|---|
| `text` | string | Word text. |
| `accuracy` | number | Judged by the word's weakest sound. |
| `completeness` | number | Fraction of the word's syllables detected. |
| `start_ms`, `end_ms` | number | Offsets in the audio, milliseconds. |
| `char_start`, `char_end` | integer | Character range (end exclusive) of the word in `text`. `-1` for Japanese and for extra words not in the expected text. |
| `is_scored` | boolean | `false` when the word couldn't be scored (no reference pronunciation); its `accuracy` is then not a verdict. |
| `is_error` | boolean | `true` when the word was mispronounced or skipped: the verdict to mark it wrong. Erroneous words have `accuracy` below 0.7, accepted words 0.7 or above. Always `false` when `is_scored` is `false`. |
| `reading` | string \| null | Japanese: the word in Hepburn romaji, long vowels with macrons (`"tōkyō"`). `null` in other languages. |
| `hesitation_ms` | number \| null | Pause before or inside the word beyond the speaker's usual gap, ms; `null` if none. Pauses at punctuation never count. |
| `syllables` | Syllable[] | Per-syllable results, below. |

### Syllable

| Field | Type | Description |
|---|---|---|
| `text` | string | Syllable text, e.g. `"Mor"`. |
| `expected_ipa` | string | Expected IPA. |
| `detected_ipa` | string | IPA heard in the audio. |
| `accuracy` | number | Phoneme-level accuracy. |
| `completeness` | number | Fraction of expected phonemes detected. |
| `duration_ms`, `start_ms`, `end_ms` | number | Timing in milliseconds. |
| `is_missing` | boolean | `true` if the speaker skipped this syllable. |
| `is_extra` | boolean | `true` if the speaker said something not in the expected text. |
| `is_scored` | boolean | `false` when the syllable has no reference IPA; `accuracy` is then not a verdict (distinguish it from a real 0). |
| `reading` | string \| null | How the syllable is read: Chinese pinyin with tone marks (`"hǎo"`), Japanese romaji per mora (`"ka"`). `null` in other languages. |
| `prosody` | Prosody \| null | Tone (Chinese) or pitch accent (Japanese) as judged by the model, below. `null` in other languages. |

### Prosody

The model's verdict on how a syllable was pitched: the tone of a Chinese character, or the pitch accent of a Japanese mora. `null` in other languages.

Experimental: tuned to avoid false alarms, so `is_error: true` is very likely right, but subtle slips are often not flagged yet. In Chinese a wrong tone also sets the word's `is_error`; in Japanese it only shows on the mora.

| Field | Type | Description |
|---|---|---|
| `kind` | `"tone"` \| `"pitch"` | `tone` for Chinese, `pitch` for Japanese. |
| `expected` | string | Chinese: the tone, `"1"` to `"5"` (5 = neutral), or `"2\|3"` where third-tone sandhi allows both. Japanese: `"H"` or `"L"`, the Tokyo accent in context. |
| `heard` | string | The tone or pitch the model found most likely, same values (a single tone for `"2\|3"`). It can differ from `expected` without being an error: use `is_error` for the verdict. |
| `score` | number | Probability of the expected tone or pitch. |
| `is_error` | boolean | `true` when the expected tone or pitch is very unlikely (`score` below our cut-off). In Chinese a wrong tone marks the word as an error. |

### Reading the results

- Mark errors with `is_error`, not with your own cut-off on `accuracy`. `is_error` is tuned to avoid false alarms: when it is true, the word was very likely said wrong. `accuracy` is the grade: below 0.7 for words marked wrong, 0.7 or above for accepted ones.
- Syllables show where. A syllable can score below 0.7 inside a word that is not marked as an error: one sound was off, but not enough to call the whole word wrong. Show it as a hint (for example a light highlight on that syllable), not as an error.
- `detected_ipa` is what the model heard. It can differ from `expected_ipa` even when the pronunciation is fine (accents, natural variation), so judge by `accuracy` and `is_error`, not by comparing the two strings.
- Single words and short phrases (under 3 words): `accuracy` is never higher than the words' own scores, so a word marked wrong cannot get a high exercise score.
- Tone and pitch: show `reading` (pinyin or romaji) with each syllable and mark those with `prosody.is_error`, naming the tone heard ("tone 2 instead of 3"). For Japanese, an H/L line over the morae is often clearer than single labels. Show it as a hint: the check is experimental.
- Chinese: each character is one word with one syllable, and its `char_start` / `char_end` index `text`. A character with the right sounds but a wrong tone has `is_error` true; `prosody.heard` says which tone was heard.
- When `assessable` is false, don't mark words as errors: tell the user the recording couldn't be graded (with `reason`, e.g. "we couldn't hear you" for `no_speech`) and ask them to try again.
- When `is_scored` is false there was nothing to judge (no reference pronunciation): show the word or syllable neutrally, not as an error or a 0.

## Errors

Errors are JSON: `{"error": {"code": "HTTP_<status>", "message": ..., "path": ..., "method": ...}}`, except 422, which uses FastAPI's `{"detail": [...]}`.

| Status | Meaning | What to do |
|---|---|---|
| 400 | Invalid audio, or longer than 60 seconds | Send WAV, MP3, M4A, OGG, FLAC or WEBM, at most 60 s. |
| 401 | Missing, malformed or invalid API key | Send `Authorization: Bearer lx_...`. |
| 403 | No active API subscription | Subscribe at https://lingolix.com/api-portal/pricing. |
| 413 | Upload over 10 MiB | Encode to MP3/Opus instead of WAV. |
| 422 | Missing `speechdata` or malformed form fields | Fix the request. |
| 402 | Monthly quota used up, and overage is off or its spend cap is reached | `error.message` is an object with `error` (`quota_exceeded`, `overage_disabled` or `overage_cap_reached`), `message`, `plan`, `remaining_minutes` and `upgrade_url`. Turn on overage, raise the cap, upgrade, or wait for the next billing period. Don't retry. |
| 429 | Too many requests (20 per second, 600 per minute, per IP) | Wait for the seconds in `Retry-After`, then retry. |
| 5xx | Temporary failure | Retry after a short delay with backoff. |

## Quotas

Usage is metered in audio minutes per month, shared across all keys of a subscription. The free tier has 15 minutes and is a hard limit (402 when used up). Paid plans have 180 to 13,200 minutes. Overage is off by default, so a paid plan also returns 402 once its minutes are used up. Turn overage on at https://lingolix.com/api-portal/subscription to keep going at €0.02 to €0.05 per minute (depending on plan), collected at the end of the month; a spend cap limits it. Usage is shown at https://lingolix.com/api-portal/dashboard.

Every scored request returns two headers:

| Header | Meaning |
|---|---|
| `X-Quota-Limit` | Included minutes per month. |
| `X-Quota-Remaining` | Included minutes left after this request, e.g. `42.37`. `0.00` once you are using overage. |

## Migrating from v3

v3 (`POST /api/pronunciation/v3/check`) keeps working until **1 March 2027** and then returns 410. Its responses carry `Deprecation` and `Sunset` headers. To move to v4, change the path to `/v4/check` and check three things:

| | v3 | v4 |
|---|---|---|
| Monthly quota used up | 429 | 402 (429 now only means rate-limited) |
| `pitch` on each syllable | sent | removed: use `prosody` for Chinese tones and Japanese pitch accent |
| `language_code` | optional, default `ja` | required (422 if missing) |

Everything else is the same. The SDKs use v4 from version 0.5.0.
