# Evaluate Gladia on your own audio (WER test)

Last updated: 2026-11-12

**The problem.** Public benchmarks are measured on someone else's audio. Your accents, your microphones, your jargon
and your phone lines decide how well a speech-to-text API works for you, and the only way to know is to test it on
your own recordings.

**What a WER test gives you.** The **word error rate** (WER) counts the words a transcript gets wrong against a
reference written by a person: substituted, missing and extra words, divided by the words of the reference. `0.08`
means 8 errors per 100 words. Run the same files through each API you compare, with the same normalization, and the
lowest WER wins on your audio. For Gladia's own published figures and how they are measured, see the
[benchmarks](https://www.gladia.io/competitors/benchmarks).

## At a glance

| What | How |
|---|---|
| You need | 30 to 60 minutes of your audio, cut in files, and a reference transcript per file |
| Transcribe | the live API (as your product will), or a pre-recorded job for files |
| Compare | each transcript to its reference, both normalized the same way |
| Read | the WER over all files: the sum of the errors over the sum of the reference words |

## Step by step

### 1. Pick representative audio

Take recordings like the ones your product will get: the same channel (phone, laptop, studio), the same languages and
accents, the same vocabulary. Thirty minutes to an hour, from several speakers, is enough to rank vendors; a single
clean file says little.

### 2. Write the references

Have a person transcribe each file word for word, every hesitation they hear included or every one left out, but the
same rule for all files. Save each next to its audio: `call-01.wav` and `call-01.reference.txt`.

### 3. Transcribe and score

The programs below stream a WAV file to the live API, as your product will, keep the final transcript, and print its
WER against the reference next to it. Put your API key in the `GLADIA_API_KEY` environment variable, then run
`python evaluate_wer.py call-01.wav`.

**Python SDK**

```python title="evaluate_wer.py"
# pip install -U "gladiaio-sdk>=2.2"
import os
import sys
import threading
import time
import unicodedata
import wave
from pathlib import Path

from gladiaio_sdk import GladiaClient

API_URL = os.environ.get("GLADIA_API_URL", "https://eu1.api.gladia.io")
API_KEY = os.environ["GLADIA_API_KEY"]

def normalize(text):
    """Lowercase words without punctuation: apply the same to every vendor's transcript and to the reference."""
    text = unicodedata.normalize("NFKC", text).lower().replace("’", "'")
    # keep letters, their marks (Hindi, Thai, Arabic vowels) and digits; any other character separates words
    words = "".join(c if c == "'" or unicodedata.category(c)[0] in "LMN" else " " for c in text).split()
    return [w.strip("'") for w in words if w.strip("'")]  # 'no' is no; don't stays don't

def errors(reference, hypothesis):
    """Substitutions + deletions + insertions to turn the reference into the hypothesis (word edit distance)."""
    row = list(range(len(hypothesis) + 1))
    for i, ref_word in enumerate(reference, 1):
        previous, row[0] = row[0], i
        for j, hyp_word in enumerate(hypothesis, 1):
            previous, row[j] = row[j], min(row[j] + 1, row[j - 1] + 1, previous + (ref_word != hyp_word))
    return row[-1]

audio_path = Path(sys.argv[1])  # a 16-bit PCM WAV file
reference = normalize(audio_path.with_suffix(".reference.txt").read_text(encoding="utf-8"))
with wave.open(str(audio_path)) as wav:
    rate, channels = wav.getframerate(), wav.getnchannels()
    audio = wav.readframes(wav.getnframes())

config = {"encoding": "wav/pcm", "sample_rate": rate, "bit_depth": 16, "channels": channels, "model": "solaria-3"}
client = GladiaClient(api_key=API_KEY, api_url=API_URL)
session = client.live_v2().start_session(config)
ended, errors_seen, finals = threading.Event(), [], []

@session.on("message")
def on_message(message):
    if message.type == "transcript" and message.data.is_final:
        finals.append(message.data.utterance.text)

session.on("error", errors_seen.append)
session.once("ended", lambda _: ended.set())

# Stream once the socket is open: a stop sent while it opens can pass the audio queued until then.
connected = threading.Event()
session.once("connected", lambda _: connected.set())
session.once("ended", lambda _: connected.set())  # a session that never connects ends
session.on("error", lambda _: connected.set())
if session.status == "connected":  # it opened before the listener above
    connected.set()
if not connected.wait(timeout=30) or errors_seen or ended.is_set():
    sys.exit(1)  # no open session to stream to

step = rate * channels * 2 // 10  # 100 ms of audio per chunk
for start in range(0, len(audio), step):
    session.send_audio(audio[start : start + step])
    time.sleep(0.1)  # at the pace of real time: the live API closes a session far ahead of it
session.stop_recording()
ended.wait(timeout=60)
if errors_seen or not ended.is_set():
    sys.exit(1)

hypothesis = normalize(" ".join(finals))
wrong = errors(reference, hypothesis)
wer = f"{wrong / len(reference):.1%}" if reference else "n/a (empty reference)"  # silence, hold music
print(f"{audio_path.name}: {wrong} errors / {len(reference)} reference words, WER {wer}")
```

**JavaScript SDK**

```js title="evaluate_wer.mjs"
// npm install @gladiaio/sdk
import { readFileSync } from "node:fs";
import { basename } from "node:path";
import { setTimeout as sleep } from "node:timers/promises";
import { GladiaClient } from "@gladiaio/sdk";

// Lowercase words without punctuation: apply the same to every vendor's transcript and to the reference.
const normalize = (text) =>
  text
    .normalize("NFKC")
    .toLowerCase()
    .replaceAll("’", "'")
    .split(/[^\p{L}\p{M}\p{N}']+/u)
    .map((word) => word.replace(/^'+|'+$/g, "")) // 'no' is no; don't stays don't
    .filter(Boolean);

// Substitutions + deletions + insertions to turn the reference into the hypothesis (word edit distance).
function errors(reference, hypothesis) {
  const row = Array.from({ length: hypothesis.length + 1 }, (_, j) => j);
  reference.forEach((refWord, i) => {
    let previous = row[0];
    row[0] = i + 1;
    hypothesis.forEach((hypWord, j) => {
      const here = Math.min(row[j + 1] + 1, row[j] + 1, previous + (refWord === hypWord ? 0 : 1));
      previous = row[j + 1];
      row[j + 1] = here;
    });
  });
  return row[hypothesis.length];
}

const audioPath = process.argv[2]; // a 16-bit PCM WAV file
const reference = normalize(readFileSync(audioPath.replace(/\.[^./]+$/, ".reference.txt"), "utf8"));
const { sampleRate, channels, pcm } = readWav(audioPath);

const client = new GladiaClient({
  apiKey: process.env.GLADIA_API_KEY,
  apiUrl: process.env.GLADIA_API_URL ?? "https://eu1.api.gladia.io",
});
const session = client.liveV2().startSession({
  encoding: "wav/pcm",
  sample_rate: sampleRate,
  bit_depth: 16,
  channels,
  model: "solaria-3",
});

const finals = [];
session.on("message", (message) => {
  if (message.type === "transcript" && message.data.is_final) finals.push(message.data.utterance.text);
});
session.on("error", (error) => {
  console.error(error);
  process.exitCode = 1;
});
session.once("ended", () => {
  if (process.exitCode) process.exit(); // the session failed: no score from part of the audio
  const hypothesis = normalize(finals.join(" "));
  const wrong = errors(reference, hypothesis);
  // an empty reference (silence, hold music) has no rate: count its errors in the total anyway
  const wer = reference.length ? `${((100 * wrong) / reference.length).toFixed(1)}%` : "n/a (empty reference)";
  console.log(`${basename(audioPath)}: ${wrong} errors / ${reference.length} reference words, WER ${wer}`);
  process.exit();
});

const step = (sampleRate * channels * 2) / 10; // 100 ms of audio per chunk
for (let start = 0; start < pcm.length; start += step) {
  session.sendAudio(pcm.subarray(start, start + step));
  await sleep(100); // at the pace of real time: the live API closes a session far ahead of it
}
session.stopRecording();

function readWav(path) {
  const file = readFileSync(path);
  let fmt, pcm;
  for (let pos = 12; pos < file.length; ) {
    const id = file.toString("ascii", pos, pos + 4);
    const size = file.readUInt32LE(pos + 4);
    if (id === "fmt ") fmt = { channels: file.readUInt16LE(pos + 10), sampleRate: file.readUInt32LE(pos + 12) };
    if (id === "data") pcm = file.subarray(pos + 8, pos + 8 + size);
    pos += 8 + size + (size % 2);
  }
  return { ...fmt, pcm };
}
```

**HTTP**

To score files after the fact, as a pre-recorded job ([Transcribe a file](/pre-recorded/transcribe-a-file/)), upload
the file (here `call.wav`):

```bash
curl -X POST https://eu1.api.gladia.io/v2/upload \
  -H "x-gladia-key: $GLADIA_API_KEY" \
  -F "audio=@call.wav"
```

Start a job on the `audio_url` it returns, with the model and the language you evaluate:

```bash
curl -X POST https://eu1.api.gladia.io/v2/pre-recorded \
  -H "x-gladia-key: $GLADIA_API_KEY" \
  -H "content-type: application/json" \
  -d '{"audio_url": "https://eu1.api.gladia.io/file/0199d7a2-0000-7000-8000-00000000f11e", "model": "solaria-3", "language_config": {"languages": ["en"]}}'
```

Read the job (its `id` in `$JOB_ID`) until its `status` is `done`:

```bash
curl https://eu1.api.gladia.io/v2/pre-recorded/$JOB_ID \
  -H "x-gladia-key: $GLADIA_API_KEY"
```

Its `result.transcription.full_transcript` is the hypothesis: score it against the reference with the `normalize`
and the word edit distance of the programs.

Run it on every file, add up the errors and the reference words, and divide: that is your WER. Averaging the WER of
each file instead gives a short file as much weight as a long one.

### 4. Compare like with like

Run the same files through every API, with each one's own best settings for your case (language, model,
[custom vocabulary](/features/custom-vocabulary/)), and score every transcript with the **same** `normalize`. Then
read the errors themselves, not only the rate: a wrong product name costs more than a missing "uh".

## Limits and gotchas

- **Normalization decides the number.** Punctuation, case, "20" against "twenty", "okay" against "OK": an unnormalized
  comparison counts style as errors. Use one normalizer for everything, and set
  [numerals](/features/numerals/) the same way for every API you compare.
- **The reference is a transcript too.** A rushed reference inflates every vendor's WER; check a sample of it.
- **Set the language** when you know it ([language detection](/languages/language-detection/)): detection on the
  first words of a short clip can pick the wrong one and fail the whole file.
- **Live and pre-recorded differ.** A live transcript is decided while people speak; a file transcribed after the fact
  sees the whole call. Test the mode your product will use.
- **Hesitations and fillers.** Decide once whether "uh", "um", repeated words count, apply it to the references, and
  drop them from the transcripts in `normalize` if they do not.
- **A few minutes is noise.** Two vendors 1 point apart on ten minutes of audio are tied.

## Related pages

- [Speech-to-text models](/introduction/models/)
- [Custom vocabulary](/features/custom-vocabulary/)
- [Recommended parameters](/live/recommended-parameters/)
