Skip to main content
Follow along with the runnable example. This guide walks through the Text replacements example in corti-examples — bootstrap your build from it or use it as reference.
Replacements rewrite spoken phrases in the final transcript — for example "BID""twice daily". They are supplied in the dictation configuration as a list of { find, replace } rules and applied server-side as the last step before a transcript message is returned. This guide shows how to configure replacements through the Dictation Web Component and manage a reusable rule set.
For how replacements behave — case-insensitive matching, ordering relative to command detection, the per-connection limit, and worked examples — see the Replacement Rules reference. This page focuses on wiring them into your app.

Configure replacements

Add a replacements array to your dictationConfig. Each rule is a { find, replace } pair.
dictationConfig is an object, so it must be set as a JavaScript property — not an HTML attribute. Setting it re-applies on the next connection; rebuild and reassign the config when your rule set changes.
Because replacements are applied to the final text only, they never appear in interim results, and no special client-side handling is needed to receive them — the substituted text arrives inside the normal transcript message’s data.text.

Manage a rule set

In real apps the rules are rarely hard-coded — they come from a catalog plus user-defined entries. Model each rule with a stable id so it can be edited, removed, or protected, then derive the config array from the active set.
JavaScript
Persist a user’s rule set per API client (e.g. keyed by clientId:tenant) so their replacements follow them across sessions without leaking between tenants.

Export and share a rule set

To move a rule set between environments or check it into source control, serialize it in the config shape so it round-trips cleanly:
corti-replacements.json

Next steps

Replacement Rules

Matching semantics, limits, and worked examples for the replacements feature.

Keyterms

Boost recognition of domain vocabulary before it reaches the transcript.

Example code

The complete, runnable Text replacements example in corti-examples.
Please contact us for help or questions.