# Audio redaction

Last updated: 2026-11-19

Someone has to hear the caller. Some of what the caller says must not reach them. **Audio redaction**
echoes the caller's audio back to your side with the parts you chose replaced by a beep: the caller is
transcribed as usual, the speech flows without a pause, and the other end hears a beep where the value
is said.

The beep starts the moment the entity is named, not before: the engine reads the speech in partials,
so the first syllables of a value may already be on their way when the beep begins, and a number said
with no lead-in ("ok so, 06 12…") is named at its end. [How early the beep starts](#how-early-the-beep-starts)
gives the measured bound; read it before you rely on the feature for a compliance obligation.

## At a glance

| | |
|---|---|
| Live API | `audio_redaction` |
| 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/)) |

## What it is for

Two problems, one mechanism.

**A caller trying to take the deal off the platform.** On a marketplace, a booking platform or a
delivery platform, the two people on the call have every interest in exchanging a phone number or an
email address and finishing the transaction directly: the platform's fee, its guarantees, the record
of what was agreed all go with it. The number is said in the first minutes, in the middle of a
sentence, and nothing in the transcript stops the other side from hearing it. Beep the phone number,
the email address and the messaging handle, and the call still works: the parties talk, the platform
stays in the deal.

**Personal data reaching someone who must not have it.** An agent, a driver, a partner joining a
conference call, an outsourced support team: a card number, a bank account, a social security number
read out loud. Masking the transcript is not enough, the audio itself carries the value; deleting the
audio is not either, the rest of the conversation has to be heard.

Both cases are the same thing on the wire: from the moment a selected entity is named until it
closes, the audio your side receives carries a beep in its place, and the transcript is unchanged.

## Turn it on

```json
{ "audio_redaction": true }
```

`true` beeps the PII preset (names, phone numbers, emails, card numbers, bank accounts, addresses and
the rest) at 1 kHz. Choose what to catch and how it sounds with the object:

```json
{
  "audio_redaction": {
    "entities": ["phone_number", "credit_card", "ssn"],
    "threshold": 0.5,
    "frequency_hz": 1000
  }
}
```

| key | default | meaning |
|---|---|---|
| `entities` | the `pii` preset | the entity types to beep, in the `pii` option's syntax: a preset name (`pii`, `pci`, `phi`, `gdpr`, `hipaa`), a list of types, or `{"enable": [...], "disable": [...]}` |
| `threshold` | `0.5` | the tagger's score floor, from 0 to 1 |
| `frequency_hz` | `1000` | the beep's tone, 100 to 20000 Hz, below half the session's sample rate (a 8 kHz telephone line allows up to 3999 Hz) |

`entities` may name any type `named_entity_recognition` tags.

### Two recipes

Keeping the deal on the platform: beep the ways the two parties can reach each other outside it.

```json
{
  "audio_redaction": {
    "entities": ["phone_number", "email_address", "url", "username", "location_address"]
  },
  "numerals": true
}
```

Keeping financial and identity data off the line: a support call, a payment, an identity check.

```json
{
  "audio_redaction": {
    "entities": ["credit_card", "cvv", "credit_card_expiration", "bank_account",
                 "routing_number", "ssn", "account_number", "healthcare_number",
                 "passport_number", "driver_license"]
  },
  "numerals": true
}
```

Both recipes select number types, so besides the model's entities a trailing run of four digits in
the transcript starts the beep on its own (a number said with no lead-in, which the model names only
at its end). That rule counts digits: a number said in words ("zero six twelve") stays words unless
the session sets `numerals: true`, which writes it in digits before the model and the rule read it.
Without it, a selection of number types only (the second recipe) skips the model on a partial with
no digit, and a number said in words is not beeped at all. Set it whenever callers may say numbers
in words; the recipes above do.

In a session, with the SDKs or over HTTP. Each program streams a 16-bit WAV file with audio redaction on and prints
the final transcripts; the beeped audio comes back in `audio_passthrough` messages
([below](#the-audio-comes-back-beeped)). Put your API key in the `GLADIA_API_KEY` environment variable, then run
`python audio_redaction.py call.wav`.

**Python SDK**

```python title="audio_redaction.py"
# pip install -U "gladiaio-sdk>=2.2"
import os
import sys
import threading
import wave

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"]

with wave.open(sys.argv[1]) as wav:  # a 16-bit PCM WAV file
    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",
    "language_config": {"languages": ["en"]},
    "audio_redaction": {"entities": ["phone_number", "email_address"]},
}

client = GladiaClient(api_key=API_KEY, api_url=API_URL)
# a dict is sent as is: the Gladia Enterprise options included
session = client.live_v2().start_session(config)
ended, errors = threading.Event(), []

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

session.on("error", errors.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 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])  # live audio: send each chunk as it is captured
session.stop_recording()

ended.wait(timeout=60)
sys.exit(1 if errors or not ended.is_set() else 0)
```

**JavaScript SDK**

```js title="audio_redaction.mjs"
// npm install @gladiaio/sdk
import { readFileSync } from "node:fs";
import { GladiaClient } from "@gladiaio/sdk";

const { sampleRate, channels, pcm } = readWav(process.argv[2]); // a 16-bit PCM WAV file

const config = {
  encoding: "wav/pcm",
  sample_rate: sampleRate,
  bit_depth: 16,
  channels,
  model: "solaria-3",
  language_config: { languages: ["en"] },
  audio_redaction: { entities: ["phone_number", "email_address"] },
};

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(config);

session.on("message", (message) => {
  if (message.type === "transcript" && message.data.is_final) console.log(message.data.utterance.text);
});
session.on("error", (error) => {
  console.error(error);
  process.exitCode = 1;
});
session.once("ended", () => 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)); // live audio: send each chunk as it is captured
}
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**

Create the session, then stream its audio to the returned `url` ([Live WebSocket](/api-reference/v2/live/websocket/)):

```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",
    "language_config": {
      "languages": [
        "en"
      ]
    },
    "audio_redaction": {
      "entities": [
        "phone_number",
        "email_address"
      ]
    }
  }'
```

Audio redaction runs on the same model as `named_entity_recognition` and `pii`, so a platform that
offers those offers it (`GET /v2/live/capabilities` lists it under the model's add-ons). It is a
setting of the whole session: it cannot be changed mid-call.

## Try it in the console

The console has the feature as its own product, **Products › Audio redaction**: choose what to
beep (a preset such as Contact details, or the entity types one by one) and the beep's tone, then
start a session from your microphone, a file or one of the app's samples. The panel shows
**Beeping · Phone number** the moment the engine names it, and lists the detections of the
session; the audio you hear is the echoed stream itself, beeped by the inference. It plays through
your speakers, so the panel has a level and a mute: use headphones, or turn it down, or the room
feeds back into the microphone.

The live playground (Sessions › Live) has the same thing as an **Audio redaction** switch among
the add-ons, with the PII preset and the beep's frequency.

## The audio comes back beeped

Every packet you send is echoed back as an `audio_passthrough` message: the caller's own audio, in
the encoding and the rate you sent, so you play it back exactly as you received it.

```json
{
  "type": "audio_passthrough",
  "session_id": "0199…",
  "created_at": "2026-11-10T12:00:01.240Z",
  "data": {
    "encoding": "pcm_s16le",
    "sample_rate": 16000,
    "channels": 1,
    "audio": "UklGRiQAAABXQVZFZm10…",
    "start": 12.34,
    "end": 12.44,
    "redacted": {"0": "phone_number"}
  }
}
```

`start` and `end` place the audio on the session's timeline, in seconds. `redacted` names the
entity beeped on each channel, by channel index: empty while nothing is being
beeped, so your UI can show "the caller is reading out a number" if it wants to. A channel that is
being beeped has its samples replaced by the tone; the other channels carry the caller's audio
untouched, byte for byte.

The tone is as loud as the caller: its amplitude is the level of their clear audio just before the
entity (a running average of the last 200 ms, per channel), held for the whole beep, between a
floor of -34 dBFS on a silent line and a ceiling of -12 dBFS. A quiet caller gets a quiet beep
rather than a fixed tone 10 to 15 dB above their voice, which is painful on headphones; two
channels beep at their own callers' levels.

The beep's level is never measured on the speech it replaces: a tone that followed the redacted
number's own loudness would carry that number's syllables, and so how many digits it has and how
they group. One beep, one amplitude.

Play `audio` as it arrives. It follows the packets you sent, in order, at the rate you sent them.

## How early the beep starts

The engine reads the caller's speech in partial transcripts, and a partial trails its audio by up
to one model chunk (80 ms to 960 ms depending on the model's latency profile). The beep starts at
the first packet echoed after the partial that names the entity, so the beginning of the number
may already be on its way: it is the earliest point at which the entity is known, and it is the
same detection your transcript uses.

Measured on the in-process harness (the real engine loop, hub and front end around a scripted
model, on solaria-1, solaria-2, solaria-3, solaria-4 and trantoria-1): the beep starts 0 to 80 ms
after the partial that named the entity, one echoed packet at most, and it starts before the
number ends on every engine.

What makes it earlier:

- **A lead-in** ("my phone number is", "call me at", "card number is", "my email is", …) starts
  the beep before the value, when that entity type is selected. It also fires on a two-word
  prefix ("phone number", "call me") and while the next word grows ("phone number i"), so the
  beep is already on when the first digit arrives. The beep stops if the next words are not the
  value ("the phone number is public").
- **A number read as digits** is recognised from its second group ("06 12", 0.86 on the PII model):
  the beep starts within the first two groups.
- **A number said with no lead-in** ("ok so, 06 12 34 56 78") is not named by the model until its
  end. When a number type is selected, a trailing run of four digits in the transcript starts the
  beep on its own, so a bare number is caught as soon as four digits are in.
- **A number read in words** ("zero six twelve") is harder for the model, and the four-digit rule
  does not read words. With `numerals: true` the session writes it in digits before either reads
  it. Without it, a selection made only of number types (the second recipe) never asks the model
  about a partial with no digit, so a number said in words is not beeped at all; with other types
  selected, the beep waits for the model to name the number, if it does.

The beep continues while the partial still ends inside the entity, and stops when it closes (the
partial no longer ends inside it). A pause inside a number ("06 12… 34 56 78") keeps it going as
long as the next partial still holds the digits; a partial that starts fresh with the rest of the
number is beeped again once the tagger (or the four-digit rule) names it.

## What it does not change

- **The transcripts.** `audio_redaction` beeps the audio only: the final and partial transcripts are
  what they were. Add `pii` to redact them too, and the two work together (`pii` masks the text,
  `audio_redaction` beeps the audio).
- **The session's result, the callback and the recording.** The audio redaction is what your client
  receives on the WebSocket; it does not rewrite the audio stored by the recording feature.
- **A session without the option.** Nothing is echoed, and the packets the engine receives are the
  same as before.

## Limits and gotchas

- **One beep per detection, not per digit.** The unit beeped is the entity: a card number beeps as a
  whole, from its detection to its end, at the frequency you chose.
- **The tagger failing fails closed.** If the entity model cannot answer (a GPU fault), the audio is
  beeped until it answers again: a beep too many costs a second of audio, a beep too late leaks the
  number.
- **The beep is a delay, not a guarantee of zero.** Without a lead-in it starts when the entity is
  named: the syllables already spoken are on their way. A lead-in beeps before the value; the
  model names a number read as digits from its second group; the four-digit rule catches a bare
  run of digits. A number said in words needs `numerals: true` to be read as digits at all.
- **A lead-in can beep a second of clear speech.** "The phone number is public" beeps until
  "public" lands. Prefer that over leaking the number.
- **The entity model must run on the GPU.** An inference whose named-entity model runs on the CPU
  refuses the option at the session's start: the partials' tagging runs
  on the step of every session of that host, and a CPU model would slow them all.
- **`frequency_hz` must fit the line.** A 8 kHz telephony session cannot carry a 4 kHz beep: the
  session is refused at its start with a `400` naming the frequency. Use 1000 Hz (the default) or
  anything below half the sample rate.
- **A selection of number types costs less.** The entity model reads a partial only when its
  end holds a digit when every selected type is a number (phone, card, account…), so a session
  beeping numbers pays for the model only while numbers are said. A selection with names or
  emails reads every changed partial.
- **A handoff loses a moment of echo, never leaks one.** When the session moves to another
  inference host (a rollout, a rebalance), the gateway replays the audio not yet finalized to the
  new host and drops that host's echoes of it: the far end already heard that audio, beeped, from
  the host before. The audio in flight at the moment of the move is not echoed at all.
- **Your audio comes back, so size for it.** An `audio_redaction` session receives as much audio as it
  sends: budget the bandwidth of the caller's stream in the other direction too.

## Related pages

- [PII redaction](/features/pii-redaction/)
- [Named entity recognition](/features/named-entity-recognition/)
- [Transcribing phone calls (8 kHz, μ-law, Twilio, SIP)](/live/telephony/)
