Skip to main content
Automatically filter profanity from streaming transcripts in real time.

Overview

Streaming profanity filtering lets you automatically mask profane words in your streaming transcripts in real time. When enabled, the API replaces profane words with asterisks in both partial and final turns before sending them to the client. The mask uses the first letter of the word followed by n - 1 asterisks (for example, shit becomes s***). Apostrophes, capitalization, and surrounding punctuation are preserved (for example, shit's becomes s***'s). Profanity filtering supports all streaming models: u3-rt-pro, universal-streaming-english, and universal-streaming-multilingual. It also works alongside other features such as format_turns and PII redaction.
Pre-recorded profanity filteringFor profanity filtering on pre-recorded audio, see Filter profanity from transcripts.

Connection parameters

ParameterTypeRequiredDefaultDescription
filter_profanitybooleanNofalseEnable real-time profanity filtering. When true, profane words in both partial and final turns are masked with asterisks (first letter preserved). The server accepts the truthy strings true, 1, and yes. Invalid values cause the WebSocket to close with code 3006.
include_partial_turnsbooleanNotrueWhen false, the API only sends final turns. Useful with filter_profanity: true if you display partials directly to end-users and want to avoid any unmasked profanity flashing during word completion.

Quickstart

Set filter_profanity to true when you open the WebSocket.
CONNECTION_PARAMS = {
    "sample_rate": 16000,
    "speech_model": "u3-rt-pro",
    "filter_profanity": True,
}
Suppress unmasked partials with include_partial_turns=falseProfanity filtering applies to both partial and final turns, but during word-completion an unmasked partial can briefly appear before the model resolves the word and applies the mask. If your application surfaces partials directly to end-users (for example a live caption stream or voice-agent UI), set include_partial_turns: false on the connection to suppress all partial turns and only receive masked finals. The default is true (partials enabled), so this requires an explicit opt-out.

Example output

With filter_profanity=true, a final turn might look like:
s*** is what you say when you stub your toe.
The mask preserves word length, apostrophes, and surrounding punctuation, so a word like shit's is returned as s***'s and motherfucker becomes m***********.

Troubleshooting

The streaming filter targets the same word list as pre-recorded profanity filtering and only masks words on that list. Some words you might consider profane, such as crap and damn, are intentionally not masked and pass through unchanged. If you need stricter filtering, apply your own post-processing on top of the masked transcript.
Profanity masking applies during word classification, so an unmasked partial can briefly appear before the word is fully recognized and masked. If your UI surfaces partials directly to users, set include_partial_turns: false on the connection. Final turns are always masked.