Entity detection

Learn how to use entity detection with the Speech to Text API

Overview

Entity detection comes at an additional cost. See the API pricing page for detailed pricing information.

Entity detection is a feature that allows you to detect specific words and phrases in the transcript, providing their exact timestamps. This is useful to detect credit card numbers, names, medical conditions or SSNs which can then be redacted.

When enabled, the model will detect specific entity types in the transcript and provide their exact timestamps.

For example, the following audio:

Outputs the following transcript when we specify "pii" (Personally Identifiable Information) as the entity type:

1{
2 "language_code": "eng",
3 "language_probability": 0.9869821071624756,
4 "text": "My name is Jill. My date of birth is the 12th of July 1987, and my credit card number is 4242-4242-4242-4242.",
5 "words": [
6 { "text": "My", "start": 0.099, "end": 0.259, "type": "word", "logprob": 0.0 },
7 { "text": " ", "start": 0.259, "end": 0.299, "type": "spacing", "logprob": 0.0 },
8 { "text": "name", "start": 0.299, "end": 0.42, "type": "word", "logprob": 0.0 },
9 ...
10 ],
11 "transcription_id": "Y2ZX8AxHUzTPCIualYiE",
12 "entities": [
13 {
14 "text": "Jill",
15 "entity_type": "name",
16 "start_char": 11,
17 "end_char": 15
18 },
19 {
20 "text": "12th of July 1987",
21 "entity_type": "dob",
22 "start_char": 41,
23 "end_char": 58
24 },
25 {
26 "text": "4242-4242-4242-4242",
27 "entity_type": "credit_card",
28 "start_char": 89,
29 "end_char": 108
30 }
31 ]
32}

The result shows the PII entities detected in the transcript, with their exact timestamps.

Integrating entity detection

Entity detection is integrated into the Speech to Text API by passing the entity_detection parameter to the convert method.

1import os
2from dotenv import load_dotenv
3from io import BytesIO
4import requests
5from elevenlabs.client import ElevenLabs
6
7load_dotenv()
8
9elevenlabs = ElevenLabs(
10 api_key=os.getenv("ELEVENLABS_API_KEY"),
11)
12
13audio_url = (
14 "https://storage.googleapis.com/eleven-public-cdn/documentation_assets/audio/stt-entity-detection-pii.mp3"
15)
16response = requests.get(audio_url)
17audio_data = BytesIO(response.content)
18
19transcription = elevenlabs.speech_to_text.convert(
20 file=audio_data,
21 model_id="scribe_v2", # Model to use
22 # Entity types to detect, accepts a list of specific entity types or categories.
23 # To detect all entity types, use the "all" category.
24 entity_detection=["pii"],
25)
26
27print("Entities detected:", transcription.entities)

Entity types

The following entity types are supported for detection. You can detect entire groups using pii, phi, or pci, or specify individual entity types by their label. To detect all entity types, use the all category.

LabelDescriptionRegulatory Compliance
account_numberCustomer account or membership identification numberCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
ageNumbers associated with an individual’s ageGDPR, HIPAA, Quebec Privacy Act, APPI
bank_accountBank account numbers and international equivalents, such as IBANCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
cardinalNumerical expressions in cardinal form
credit_cardCredit card numbersCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
credit_card_expirationExpiration date of a credit cardCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
cvv3- or 4-digit card verification codes and equivalentsCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
dateSpecific calendar dates, which can include days of the week, dates, months, or yearsHIPAA, Quebec Privacy Act
date_intervalBroader time periods, including date ranges, months, seasons, years, and decadesHIPAA
dobDates of birthCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
driver_licenseDriver’s permit numbersCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
email_addressEmail addressesCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
eventNames of events or holidays
filenameNames of computer files, including the extension or filepath
gender_sexualityTerms indicating gender identity or sexual orientation, including slang termsCPRA, GDPR, GDPR Sensitive, APPI Sensitive
healthcare_numberHealthcare numbers and health plan beneficiary numbersCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
ip_addressInternet IP address, including IPv4 and IPv6 formatsCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
locationMetaclass for any named location referenceGDPR, HIPAA, APPI
location_addressFull or partial physical mailing addressesCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
location_cityMunicipality names, including villages, towns, and citiesCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
location_coordinateGeographic positions referred to using latitude, longitude, and/or elevation coordinatesCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
location_countryCountry namesGDPR, APPI
location_stateState, province, territory, or prefecture namesGDPR, APPI
location_zipZIP codes (including ZIP+4), postcodes, or postal codesCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
moneyNames and/or amounts of currency
nameNames of individuals, not including personal titles such as ‘Mrs.’ or ‘Mr.‘CPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
name_givenNames given to an individual, usually at birth; often first/middle names in Western culturesCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
name_familyNames indicating a person’s family or community; often a last name in Western culturesCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
name_medical_professionalNames including the title of a medical professional, such as “Doctor”CPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
numerical_piiNumerical PII that doesn’t fall under other categoriesCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
occupationJob titles or professionsQuebec Privacy Act, APPI
ordinalNumerical expressions in ordinal form
originTerms indicating nationality, ethnicity, or provenanceCPRA, GDPR, GDPR Sensitive, Quebec Privacy Act, APPI Sensitive
passport_numberPassport numbers, issued by any countryCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
passwordAccount passwords, PINs, access keys, or verification answersCPRA, APPI
percentNumerical expressions as percentages
phone_numberTelephone or fax numbersCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
physical_attributeDistinctive bodily attributes, including terms indicating raceCPRA, GDPR, GDPR Sensitive, APPI Sensitive
ssnSocial Security Numbers or international equivalent government identification numbersCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
timeExpressions indicating clock times
urlInternet addressesCPRA, GDPR, HIPAA, Quebec Privacy Act
usernameUsernames, login names, or handlesCPRA, GDPR, APPI
vehicle_idVehicle identification numbers (VINs), vehicle serial numbers, and license plate numbersCPRA, GDPR, HIPAA, APPI
LabelDescriptionRegulatory Compliance
conditionNames of medical conditions, diseases, syndromes, deficits, disordersCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI Sensitive
drugMedications, vitamins, and supplementsCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI Sensitive
injuryBodily injuries, including mutations, miscarriages, and dislocationsCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI Sensitive
blood_typeBlood typesCPRA, GDPR, HIPAA, Quebec Privacy Act
medical_processMedical processes, including treatments, procedures, and testsCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI Sensitive
statisticsMedical statisticsHIPAA, Quebec Privacy Act
LabelDescriptionRegulatory Compliance
credit_cardCredit card numbersCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
credit_card_expirationExpiration date of a credit cardCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
cvv3- or 4-digit card verification codes and equivalentsCPRA, GDPR, HIPAA, Quebec Privacy Act, APPI
LabelDescriptionRegulatory Compliance
languageNames of natural languagesGDPR, GDPR Sensitive, APPI Sensitive
marital_statusTerms indicating marital statusAPPI Sensitive
organizationNames of organizations or departments within an organizationQuebec Privacy Act, APPI
political_affiliationTerms referring to a political party, movement, or ideologyCPRA, GDPR, GDPR Sensitive, Quebec Privacy Act, APPI Sensitive
religionTerms indicating religious affiliationCPRA, GDPR, GDPR Sensitive, Quebec Privacy Act, APPI Sensitive
routing_numberRouting number associated with a bank or financial institution
zodiac_signNames of Zodiac signs