Skip to content

Named entity recognition

The problem. A caller gives their name, their order number and a delivery date; your CRM needs those fields, not a paragraph. Named entity recognition finds them in each final transcript as it arrives: people, organizations, places, dates, amounts, emails, phone numbers and about 70 types in all.

Where it works. Every model.

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

realtime_processing.named_entity_recognition: true, Gladia’s field, does the same.

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 entities.py meeting.wav.

entities.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"
]
},
"named_entity_recognition": {
"entities": [
"name",
"organization",
"date",
"phone_number"
]
}
}
client = GladiaClient(api_key=API_KEY, api_url=API_URL)
# `named_entity_recognition` with options: 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)
elif message.type == "named_entity_recognition":
for entity in message.data.results:
print(f" {entity.entity_type}: {entity.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)

The final lists them in entities, and its text stays as it was said: start and end locate each entity’s words in text.

{
"type": "transcript",
"data": {
"id": "00_00000002",
"is_final": true,
"utterance": {
"text": "Hi, this is Marie Curie from Gladia.",
"entities": [
{ "label": "name", "id": 1, "action": "ner", "text": "Marie Curie", "start": 12, "end": 23 },
{ "label": "organization", "id": 1, "action": "ner", "text": "Gladia", "start": 29, "end": 35 }
]
}
}
}

To get them inline in the text as well, add "inline_tags": true to the session. The text is then one XML fragment: Hi, this is <ner:name id="1">Marie Curie</ner:name> from <ner:organization id="1">Gladia</ner:organization>., with start and end on each whole element, text_raw keeping the plain sentence, and the other inline elements of inline_tags (<speaker>, <sentiment/>, & written &amp;) around it.

Right after it, a named_entity_recognition message lists them with their times in the audio:

{
"type": "named_entity_recognition",
"error": null,
"data": {
"utterance_id": "00_00000002",
"results": [
{ "entity_type": "name", "text": "Marie Curie", "start": 4.9, "end": 5.6, "id": 1, "score": 0.97, "char_start": 12, "char_end": 23 }
]
}
}
option what it does
entities Which types: a preset (name, location, date, contact, financial, identifiers, pii…), a list of types and presets, or {"enable": [...], "disable": [...]}. Omitted: every type.
threshold Confidence, from 0 to 1, under which an entity is ignored. Default 0.5.
alternative_names true or {threshold, max_results, census}: the names that sound like each name found, with their probability. See Alternative names. Default off.

A parent type (name, location, date) also selects its children (name_given, name_family, location_city…). An unknown type is refused, with the list of known ones.

The types are the cloud API’s, by the same names: every type of its entity table is one here (email_address is its EMAIL_ADDRESS), its older GENDER_SEXUALITY is gender and sexuality, as its own list now names them. A live session writes them in lower case. A pre-recorded job’s named_entity_recognition.results writes them in upper case, as the cloud API does:

{
"id": "0199d7a2-6a10-7c22-8d4e-5f6a7b8c9d0e",
"kind": "pre-recorded",
"status": "done",
"result": {
"named_entity_recognition": {
"success": true, "is_empty": false, "exec_time": 0.02, "error": null,
"results": [
{"entity_type": "EMAIL_ADDRESS", "text": "privacy@gladia.io", "start": 12.4, "end": 13.5},
{"entity_type": "AGE", "text": "27 years old", "start": 23.4, "end": 23.9}
]
}
}
}

A pre-recorded job reports the 57 types the cloud API’s named entities report, and nothing else: a part of a date (day, month, year) is a DATE, an organization’s number or a brand an ORGANIZATION, and the types the cloud API never reports there (product, software, application, mac_address, education…) are left out. Live sessions report every type, brand (“Nike shoes”), software (“Excel”, “Salesforce”) and application (“the WhatsApp app”) included: selecting organization selects brand too, and product selects software and application. India’s Aadhaar number is ssn_in_aadhaar: selecting ssn selects it too, and a pre-recorded job reports it as an SSN. Every name, side by side: From Gladia’s cloud API.

Coming from Gladia’s cloud API? Its live named_entity_recognition message writes entity_type in upper case and has only entity_type, text, start and end: compare the types without case, and read the other fields as additions (Live named entities).

The problem. A caller says their name once. The transcript writes one spelling, “Mickaël Dupond”, but the same sound is spelled Michaël, Mikaël, Dupont or Dupond, and your agent books the table under the wrong one. Asking “how do you spell that?” every time is slow, and never asking is wrong too often.

The fix. Turn on alternative_names. For each first name, surname or full name found, the entity also carries the names that sound the same, taken from the census of names of the utterance’s language, each with how likely it is to be the right one. Your agent can confirm the likely spelling (“Dupont, with a t?”) instead of guessing, and skip the question when the heard spelling is clearly the most likely.

{
"encoding": "wav/pcm",
"sample_rate": 16000,
"bit_depth": 16,
"channels": 1,
"model": "solaria-3",
"language_config": { "languages": ["fr"] },
"named_entity_recognition": {
"entities": ["name_given", "name_family"],
"alternative_names": { "threshold": 0.05, "max_results": 5, "census": true }
}
}
option what it does
threshold The lowest probability, from 0 to 1, an alternative must have to be returned. Default 0.05.
max_results The most alternatives per name, from 1 to 20. Default 5.
census Add each name’s census data (frequency, share, rank, gender). Default true.

"alternative_names": true takes the defaults. Each name in the named_entity_recognition message then carries its probability, its census row and its alternatives, the most probable first:

{
"type": "named_entity_recognition",
"session_id": "0199d7a2-5c3e-7b41-9f0a-3c2d1e4f5a6b",
"created_at": "2026-11-07T15:02:11.402Z",
"error": null,
"data": {
"utterance_id": "00_00000004",
"utterance": { "text": "Bonjour, c'est Mickaël Dupond pour la réservation.", "start": 0.42, "end": 4.1, "language": "fr", "confidence": 0.93, "channel": 0, "words": [] },
"results": [
{
"entity_type": "name_family", "text": "Dupond", "start": 1.8, "end": 2.31, "id": 1, "score": 0.93,
"char_start": 23, "char_end": 29,
"probability": 0.22,
"census": { "frequency": 3105, "share": 0.0007, "rank": 1290 },
"alternatives": [
{ "name": "Dupont", "probability": 0.68, "similarity": 1.0, "census": { "frequency": 98410, "share": 0.0221, "rank": 9 } },
{ "name": "Dupons", "probability": 0.06, "similarity": 0.92, "census": { "frequency": 840, "share": 0.0002, "rank": 5120 } }
]
}
]
}
}

Reading probability. A spelling is more likely when it sounds closer to what was heard (similarity, 1 for the same sound) and when the name is more common in the census. The entity’s probability (the heard spelling’s) and its alternatives’ sum to 1. Here “Dupont” sounds exactly like “Dupond” and is far more common: it is the more likely spelling, 0.68 against 0.22.

Which names. name_given is compared with first names of the same gender (no Jeanne for Jean; unisex names always pass), name_family with surnames (no gender), and name, a full name the model did not split, with its first word as a first name and its last word as a surname; in Hungarian and Vietnamese, which write the surname first (Nagy János, Nguyễn Văn An), the first word is the surname and the last the given name. With xml_events, the alternatives are <alternative> elements inside each <entity>.

  • Some languages have no census. 37 languages have one: English, French, German, Spanish, Italian, Portuguese, Dutch, Russian, Ukrainian, Polish, Czech, Slovak, Slovenian, Croatian, Serbian, Bulgarian, Romanian, Hungarian, Greek, Turkish, Azerbaijani, Albanian, Danish, Norwegian, Swedish, Finnish, Estonian, Latvian, Lithuanian, Icelandic, Indonesian, Vietnamese, Chinese, Arabic, Hebrew, Armenian and Georgian, names written in each language’s own script. Japanese, Korean, Persian, Hindi and Thai are not offered yet. A name in another language has no alternatives key: test for the key, not for an empty list.
  • Chinese full names. An unsplit name such as 王伟 is read as its first character, the surname (王), and the rest, the given name (伟); its alternatives keep that order (汪伟, 王炜…).
  • The language is the utterance’s, not the session’s: in a bilingual call each name is looked up in the census of the sentence it was said in.
  • The first sentence may come without them. A language’s census loads when the session opens; a name said in the very first second can arrive before it is ready and carry no alternatives.
  • A redacted name has none. A type selected for PII redaction is never sent with its alternatives: they would spell it back.
  • census.rank and census.share describe the census, not your callers. A name the census does not know (a rare name) has no census and a low probability: it can still be right. Confirm, do not overwrite.
  • The text does not change. utterance.text is the sentence as said; the entities are in entities and in the named_entity_recognition message. Only inline_tags: true writes <ner:…> elements into the text.
  • Finals only. Partials are not tagged.
  • id follows the entity through the session. The same person keeps id 1, even when only their first name is heard again. start/end on the utterance and char_start/char_end in the message locate the entity in text (its words, or its element with inline_tags), not in text_raw.
  • The message is not stored. The named_entity_recognition messages are not part of the session’s result; the entities of each utterance are. Store the messages yourself (WebSocket or callback) if you need their audio times.
  • If tagging fails on a final, the message comes with error set and that final has no words. Rare; the session goes on.
  • Personal data stays visible. Entities are tagged, not hidden: use PII redaction to remove them. Both together: the types selected for redaction are redacted, the others tagged.
symptom cause fix
users see <ner:name id="1"> in your interface inline_tags: true with text displayed as is drop inline_tags, display text_raw, or render the elements
no named_entity_recognition message messages_config.receive_realtime_processing_events: false turn it on
rejected: … unknown entity labels (WebSocket 1011) a type that does not exist use the types and presets of the error message
too many false entities low confidence spans raise threshold