Skip to content

PII redaction

The problem. Call transcripts end up in a CRM, a data warehouse, an LLM prompt. If they contain card numbers, phone numbers or names, all of those systems now hold personal data, with the compliance work that comes with it. PII redaction removes that data from the final transcripts before you receive them.

Where it works. Every model, on Enterprise plans. On another plan, a request that asks for it is refused with 403 and the error code plan_feature_locked: contact sales to enable it.

Live APIpii
Pre-recorded (batch)pii_redaction (how)
Live modelssolaria-3 (every live model)
LanguagesEvery language of the model (supported languages)
{ "pii": true }

By default, the pii preset is redacted: names, contact details, identity, card and account numbers, dates of birth and the like.

Each program streams a 16-bit WAV file and prints what comes back. Put your API key in the GLADIA_API_KEY environment variable, then run python pii.py meeting.wav.

pii.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"
]
},
"numerals": True,
"pii": {
"entities": [
"pii",
"pci"
],
"mode": "marker"
}
}
client = GladiaClient(api_key=API_KEY, api_url=API_URL)
# `pii`: Gladia Connect, not in the SDK's types: a dict is sent as is.
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)
{
"type": "transcript",
"data": {
"is_final": true,
"utterance": {
"text": "My card number is <pii:credit_card id=\"1\"/> and my email <pii:email_address id=\"1\"/>.",
"words": [{ "word": "", "start": 3.1, "end": 3.4, "confidence": 0.95 }]
}
}
}

Right after it, a pii message lists what was redacted (WebSocket only):

{
"type": "pii",
"error": null,
"data": {
"utterance_id": "00_00000005",
"results": [
{ "entity_type": "credit_card", "id": 1, "action": "marker", "char_start": 18, "char_end": 45 },
{ "entity_type": "email_address", "id": 1, "action": "marker", "char_start": 59, "char_end": 88 }
]
}
}
{ "pii": { "entities": ["pii", "pci"], "mode": "mask", "mask_character": "#" } }
option default what it does
entities pii What to redact: presets (pii, pci, phi, contact, financial, name, location…), types, or {"enable": [...], "disable": [...]}.
mode marker marker: an element in place of the data (<pii:phone_number id="1"/>); mask: mask characters inside the element; tag: the data kept inside the element (tagging only, nothing hidden).
threshold 0.5 Confidence under which a span is not redacted. Lower: more redacted, more false positives.
mask_character * The character of mask mode.
coreference heuristics How mentions of the same data get the same id: heuristics, exact (same text only) or off.
return_entities false Also return the redacted text in the pii message (text), for your own vault.

Pre-recorded jobs: Gladia’s cloud API form

Section titled “Pre-recorded jobs: Gladia’s cloud API form”

A pre-recorded job asks for redaction as on Gladia’s cloud API (pii_redaction, pii_redaction_config) and gets the cloud API’s output: [NAME_1] markers in place of the elements above, the number shared by every mention of the same value, and # masks (PII redaction on a pre-recorded job).

Its entity_types take the cloud API’s names, upper case: its presets (GDPR, GDPR_SENSITIVE, HIPAA_SAFE_HARBOR, HEALTH_INFORMATION, PCI, CPRA, APPI, APPI_SENSITIVE, QUEBEC_PRIVACY_ACT, CCI, CORE_ENTITIES, NUMERICAL_EXCL_PCI, LIDI), each redacting what the cloud API redacts for it, and its entity types (NAME, PHONE_NUMBER…), the types of this page upper-cased. Omitted, the cloud API’s own default set. The live entities above keep their own presets, which are not the cloud API’s: Classic’s GDPR redacts the clinical content and the article 9 categories, the live gdpr only the latter. Every name, side by side: From Gladia’s cloud API.

  • No partial transcripts. Partials are never redacted, so with redaction on none is sent, on the WebSocket or to callbacks, even with receive_partial_transcripts: true. Plan your live display on finals. (mode: tag hides nothing and keeps partials.)
  • Words lose their text. A redacted final’s words keep their times and speakers, their word is empty, and text_raw is not sent.
  • The audio is not redacted. If your account records its audio, the recording still contains what was said. Ask for recording to be turned off if that matters to you (Audio recordings).
  • custom_metadata is not redacted. Do not put personal data in it.
  • Translations are redacted too. With translation on, each translation goes through the same policy before it is sent, and a masked value keeps the id it has in the final. A translation whose redaction fails, or that would still hold a masked value, is withheld (error set, no text); with mode: tag it comes untagged instead. Pre-recorded jobs redact their translations too (Translation with PII redaction).
  • Finals may come a little later while a number or an email is still being dictated, so it is redacted whole.
  • Detection is statistical. A rare format, a name spelled letter by letter, or poor audio can slip through, and ordinary words can be redacted. Tune entities and threshold on your own calls before production.
  • return_entities brings the data back. Use it only to store the values somewhere safer than your transcripts.
  • The pii message is not stored with the session’s result and is not sent to callbacks.
symptom cause fix
no partial transcripts anymore redaction on expected; use finals, or mode: tag if you only need tagging
a translation with error “pii redaction failed, the text is withheld” its redaction failed or missed a masked value expected: it is never sent in clear; show the redacted final
a card number is not redacted spoken digit by digit with long pauses, or another preset keep numerals and the number hold on, add pci
ordinary words are redacted low confidence spans raise threshold, narrow entities