Redaction
Redaction removes sensitive data, such as names, dates of birth, health conditions, and credit card numbers, from a Batch transcript. Each redacted value is replaced with a label for its entity class, such as [name_given].
Redaction is available for Batch transcription in Speechmatics SaaS, on all models. It is not available in Realtime or on-prem deployments.
Enable redaction
To enable redaction, set enable_redaction to true and list what to redact in redaction_config.entity_classes:
{
"type": "transcription",
"transcription_config": {
"language": "en",
"enable_redaction": true,
"redaction_config": {
"entity_classes": ["gdpr"]
}
}
}
This Python example submits a job with redaction enabled and prints the redacted results:
from speechmatics.models import ConnectionSettings
from speechmatics.batch_client import BatchClient
from httpx import HTTPStatusError
API_KEY = "YOUR_API_KEY"
PATH_TO_FILE = "example.wav"
LANGUAGE = "en" # Transcription language
settings = ConnectionSettings(
url="https://eu1.asr.api.speechmatics.com/v2",
auth_token=API_KEY,
)
# Define transcription parameters
conf = {
"type": "transcription",
"transcription_config": {
"language": LANGUAGE,
"enable_redaction": True,
"redaction_config": {"entity_classes": ["gdpr"]},
},
}
# Open the client using a context manager
with BatchClient(settings) as client:
try:
job_id = client.submit_job(
audio=PATH_TO_FILE,
transcription_config=conf,
)
print(f"job {job_id} submitted successfully, waiting for transcript")
# Note that in production, you should set up notifications instead of polling.
# Notifications are described here: https://docs.speechmatics.com/speech-to-text/batch/notifications
transcript = client.wait_for_completion(job_id, transcription_format="json-v2")
print(transcript["results"]) # print the redacted results
except HTTPStatusError as e:
if e.response.status_code == 401:
print("Invalid API key - Check your API_KEY at the top of the code!")
elif e.response.status_code == 400:
print(e.response.json()["detail"])
else:
raise e
Choose what to redact
Each value in redaction_config.entity_classes is either an entity class group or a specific entity class. You can mix both in one list. Start with the regulation group that matches your compliance requirements, then add or remove specific entity classes to match your own data handling guidelines.
- Regulation groups:
gdpr,gdpr_sensitive,hipaa_safe_harbor,cpra,quebec_privacy_act,appi, andappi_sensitive. Each covers the entity classes a regulation treats as personal or sensitive data. - Data type groups:
health(protected health information),pci(payment card information), andpii(personally identifiable information). - Specific entity classes: for example
name_given,dob, orcredit_card. A general class such asnameorlocationalso redacts its subclasses, such asname_givenorlocation_city.
pii is broad. It covers every class in the PII table, including dates, times, amounts of money, and organization names, so it redacts much more than the values that identify a person. Use it only when you want all of these removed.
For example, this configuration redacts everything covered by GDPR, plus given names and credit card numbers:
{
"type": "transcription",
"transcription_config": {
"language": "en",
"enable_redaction": true,
"redaction_config": {
"entity_classes": ["gdpr", "name_given", "credit_card"]
}
}
}
For every entity class and the groups that include it, see Sensitive entity classes.
Redacted output
For the utterance "Mark was born on the 25th of July 2000.", the redacted JSON transcript looks like this (timings omitted):
{
"results": [
{ "type": "word", "alternatives": [{ "content": "[name_given]", "speaker": "S1" }] },
{ "type": "word", "alternatives": [{ "content": "was", "speaker": "S1" }] },
{ "type": "word", "alternatives": [{ "content": "born", "speaker": "S1" }] },
{ "type": "word", "alternatives": [{ "content": "on", "speaker": "S1" }] },
{ "type": "word", "alternatives": [{ "content": "the", "speaker": "S1" }] },
{ "type": "word", "alternatives": [{ "content": "[dob]", "speaker": "S1" }] },
{ "type": "punctuation", "alternatives": [{ "content": ".", "speaker": "S1" }] }
]
}
Redaction removes the original values throughout the JSON transcript.
Use redaction with sensitive data recognition
Redaction works on its own. To also label each detected value with its entity class, enable sensitive data recognition in the same job. Redacted values are then returned as entity results with an entity_class.
If enable_entities is true in a job with redaction, entities_config.detect_advanced_entities must also be true. Otherwise, the job is rejected. Redaction can't be combined with smart formatting entities.
When redaction is enabled, the transcript has no spoken_form or written_form.
Supported languages for redaction
Redaction supports all transcription languages, except:
- Bashkir
- Basque
- Esperanto
- Galician
- Interlingua
- Irish
- Maltese
- Marathi
- Mongolian
- Urdu
- Uyghur
- Welsh
For Mandarin, use the Simplified output locale (cmn-Hans, the default). Redaction of Traditional characters (cmn-Hant) isn't supported yet.
Next steps
- Label sensitive data with sensitive data recognition.
- Look up every class in Sensitive entity classes.
- See all parameters in the Batch API reference.