# Force the final transcript at end of speech (live speech-to-text)

Last updated: 2026-11-19

**The problem.** A voice agent runs its own voice activity detection: it knows the user stopped
talking. The server does not know yet: it waits for its [endpointing](/live/endpointing/) silence before it sends
the final transcript. Every turn of the conversation pays that wait twice, once in your VAD and once on the server.

**The fix.** When your VAD says the user stopped, send one message on the WebSocket:

```json
{ "type": "finalize" }
```

The open utterance is sent as a final **right away**, the session **stays open** for the next turn, and a
`finalize` message answers the request, even when there was nothing to finalize. It is the same as Deepgram's
`Finalize` and AssemblyAI's `ForceEndpoint`.

## At a glance

| | |
|---|---|
| Live API | `finalize (client message)` |
| Pre-recorded (batch) | Live only |
| Live models | `solaria-3`, `trantoria-1` (every live model) |
| Languages | Every language of the model ([supported languages](/languages/supported-languages/)) |

## Step by step

### 1. Send `finalize` when your VAD hears the end of speech

Send it on the session's WebSocket, after the audio of the utterance, and keep streaming the microphone as usual:
the request goes after the audio sent before it, so the final has every word.

### 2. Read the final, then the answer

The final arrives first, marked with `data.from_finalize`:

```json
{
  "type": "transcript",
  "session_id": "0199d7a2-5c3e-7b41-9f0a-3c2d1e4f5a6b",
  "created_at": "2026-10-27T09:00:03.000Z",
  "data": {
    "id": "00_00000003",
    "is_final": true,
    "from_finalize": true,
    "utterance": { "text": "I'd like to change my delivery address.", "start": 12.4, "end": 14.1, "language": "en", "channel": 0, "confidence": 1, "words": [] }
  }
}
```

Then the answer, one per audio channel. `finalized: true` names the final it sent by its id:

```json
{
  "type": "finalize",
  "session_id": "0199d7a2-5c3e-7b41-9f0a-3c2d1e4f5a6b",
  "created_at": "2026-10-27T09:00:03.001Z",
  "acknowledged": true,
  "error": null,
  "data": { "channel": 0, "finalized": true, "utterance_id": "00_00000003" }
}
```

`finalized: false` means there was nothing to finalize: the server's endpointing had already sent the final, or
nobody spoke since the last one. Your agent can answer at once either way.

Each program below streams a 16-bit WAV file like a microphone, sends `finalize` once the speech is over (where
your VAD would), and prints how long the final took. Put your API key in the `GLADIA_API_KEY` environment variable, then
run `python finalize.py question.wav` (or `node finalize.mjs question.wav`).

**Python**

```python title="finalize.py" e2e="skip: needs the engine, run by tests/gateway/test_live_finalize_e2e.py"
# pip install requests websockets
import asyncio
import json
import os
import sys
import time
import wave

import requests
import websockets

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

async def main(path: str) -> None:
    with wave.open(path) as wav:  # a 16-bit PCM WAV file: one question, then silence
        rate, channels = wav.getframerate(), wav.getnchannels()
        audio = wav.readframes(wav.getnframes())
    created = requests.post(
        f"{API_URL}/v2/live",
        headers={"x-gladia-key": os.environ["GLADIA_API_KEY"]},
        json={
            "encoding": "wav/pcm",
            "sample_rate": rate,
            "bit_depth": 16,
            "channels": channels,
            "model": "solaria-3",
        },
        timeout=10,
    )
    created.raise_for_status()

    async with websockets.connect(created.json()["url"]) as ws:
        step = rate * channels * 2 // 10  # 100 ms of audio per chunk
        for start in range(0, len(audio), step):
            await ws.send(audio[start : start + step])  # live audio: send each chunk as it is captured
        # your VAD heard the end of speech: ask for the final now
        asked = time.monotonic()
        await ws.send(json.dumps({"type": "finalize"}))
        async for raw in ws:
            message = json.loads(raw)
            if message["type"] == "transcript" and message["data"]["is_final"]:
                print("final:", message["data"]["utterance"]["text"])
            if message["type"] == "finalize":
                elapsed = (time.monotonic() - asked) * 1000
                print(f"finalized: {message['data']['finalized']} in {elapsed:.0f} ms")
                break
        await ws.send(json.dumps({"type": "stop_recording"}))  # or go on with the next turn
        async for _raw in ws:  # the last messages, until the server closes the connection
            pass

asyncio.run(main(sys.argv[1]))
```

**JavaScript**

```js title="finalize.mjs" e2e="skip: needs the engine, run by tests/gateway/test_live_finalize_e2e.py"
// Node.js 22 or later: fetch and WebSocket are built in
import { readFileSync } from "node:fs";

const API_URL = process.env.GLADIA_API_URL ?? "https://eu1.api.gladia.io";
const { sampleRate, channels, pcm } = readWav(process.argv[2]); // a 16-bit PCM WAV file: one question, then silence

const created = await fetch(`${API_URL}/v2/live`, {
  method: "POST",
  headers: { "x-gladia-key": process.env.GLADIA_API_KEY, "content-type": "application/json" },
  body: JSON.stringify({ encoding: "wav/pcm", sample_rate: sampleRate, bit_depth: 16, channels, model: "solaria-3" }),
});
if (!created.ok) throw new Error(`${created.status} ${await created.text()}`);

const ws = new WebSocket((await created.json()).url);
let asked;
ws.addEventListener("open", () => {
  const step = (sampleRate * channels * 2) / 10; // 100 ms of audio per chunk
  for (let start = 0; start < pcm.length; start += step) {
    ws.send(pcm.subarray(start, start + step)); // live audio: send each chunk as it is captured
  }
  // your VAD heard the end of speech: ask for the final now
  asked = performance.now();
  ws.send(JSON.stringify({ type: "finalize" }));
});
ws.addEventListener("message", ({ data }) => {
  const message = JSON.parse(data);
  if (message.type === "transcript" && message.data.is_final) console.log("final:", message.data.utterance.text);
  if (message.type === "finalize") {
    const elapsed = performance.now() - asked;
    console.log(`finalized: ${message.data.finalized} in ${elapsed.toFixed(0)} ms`);
    ws.send(JSON.stringify({ type: "stop_recording" })); // or go on with the next turn
  }
});
ws.addEventListener("error", () => {
  console.error("the WebSocket failed");
  process.exitCode = 1;
});

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**

Create the session, stream its audio to the returned `url` ([Live WebSocket](/api-reference/v2/live/websocket/)),
and send `{"type": "finalize"}` on it as a text frame when your VAD hears the end of speech:

```bash
curl -X POST https://eu1.api.gladia.io/v2/live \
  -H "x-gladia-key: $GLADIA_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "encoding": "wav/pcm",
    "sample_rate": 16000,
    "bit_depth": 16,
    "channels": 1,
    "model": "solaria-3"
  }'
```

```
final: I'd like to change my delivery address.
finalized: True in 41 ms
```

## Limits and gotchas

- **Send it at the end of speech, not at every pause.** `finalize` cuts the utterance where it is: a user who pauses
  mid-sentence and goes on gets two finals. Send it on your VAD's "user stopped speaking" event, the one that makes
  your agent answer.
- **Keep the audio flowing.** `finalize` does not stop the recording: keep sending the microphone's audio. To end the
  session, send `stop_recording`.
- **One answer per request and per channel.** A stereo session gets two `finalize` messages, one per `channel`. Two
  requests before the final get two answers after it.
- **Always answered.** `acknowledged: false` with an `error` when the request could not be forwarded: the session is
  stopping (after `stop_recording` the last finals come anyway), the session moved to another server before it
  answered, or the model's endpoint cannot finalize. The finals then come as usual. A request sent while the session
  is still connecting is held and sent once it is.
- **One every 200 ms at most.** A request sent within 200 ms of the previous one is answered `acknowledged: false`
  and not forwarded: send it once per end of speech, not with every audio chunk.
- **Every model, at once on `solaria-3` and `solaria-1`.** They send the final as soon as they read the request,
  on the audio received before it (`solaria-1`: one-channel sessions; a multichannel session closes with the next
  audio). The other models close the utterance with the next audio they receive (one chunk of their profile): keep
  the microphone streaming.
- **Answered within 3 seconds.** An utterance that held no words after all sends no final: the request is then
  answered `finalized: false` after at most 3 seconds.
- **Not with Gladia's cloud API.** `finalize` is a Gladia Enterprise message: the cloud API ignores it.
- **The result.** `GET /v2/live/{id}` holds the final in its place, `from_finalize` included in its message.

## Troubleshooting

| symptom | cause | fix |
|---|---|---|
| `finalize` answered `"finalized": false` every time | the server's endpointing sent the final before the request | nothing to do: lower your VAD's stop delay, or raise [`endpointing`](/live/endpointing/) |
| a sentence split in two finals | `finalize` sent at a pause in the middle of the sentence | send it on your VAD's end of speech, after its stop delay |
| `"acknowledged": false`, "not supported by this session's inference endpoint" | the model's endpoint runs an older image | wait for its update; the server's endpointing closes the utterances meanwhile |
| `"acknowledged": false`, "finalize sent again within 200 ms" | `finalize` sent on every audio chunk or VAD frame | send it once, on your VAD's end of speech |
| no answer at all | the message was sent as a binary frame (read as audio), or with another `type` | send `{"type": "finalize"}` as a text frame |

## Related pages

- [End of turn](/live/end-of-turn/)
- [Endpointing](/live/endpointing/)
- [Keep a live transcription session open during silence (keep-alive)](/live/keep-alive/)
