Configuration
Rewrite rules are controlled by therewrite_rules field of json_config. Its value is a single string: either a language or locale code (e.g. "en"), or "none" to disable rewriting.
json_config goes in the setup message for WebSocket sessions, or in the request body for the REST endpoint:
Default behavior
For both the production and beta models, when the selected voice has a language associated with it, the API enables that language’s rules by default. So a session using an English voice behaves as if you had passed"rewrite_rules": "en". Setting rewrite_rules yourself overrides this default.
Disabling rewriting: none
Pass "rewrite_rules": "none" to turn all rewrite rules off. Because of the language default described above, this is the only way to get unrewritten text for a voice that has a language: omitting the field enables the voice language’s rules, while "none" disables them.
Supported Languages and Locales
Each value enables the full set of rewriting rules for that language or locale:
Belgian and Swiss French share most of their rewriting with metropolitan French; the
differences are in how dates, numbers and currency amounts are spoken, so pick
fr-be or
fr-ch when your audience is in those markets.
What Gets Rewritten
With a language or locale selected, the following are expanded into the spoken form of that language:- Numbers, including negative values and large magnitudes
- Currency amounts, with the symbol before or after the amount
- Email addresses
- URLs
- Alphanumeric codes and identifiers, such as reference or product codes
- Dashed digit sequences, such as phone and account numbers
Custom Rewrites: Pronunciation Dictionaries
Rewrite rules handle general patterns (numbers, currency amounts, emails, URLs). To rewrite specific words or phrases of your own (brand names, acronyms, domain jargon), use a pronunciation dictionary instead. The dictionary is not part ofrewrite_rules or json_config: create it in the Gradium Studio (or via the pronunciations API) and pass its ID as pronunciation_id at the top level of the setup message, next to voice_id:
"en" rules to read out prices and product codes. Pronunciation dictionaries apply to WebSocket sessions only; REST requests cannot use them, and only the pattern-based rewrite_rules are available there.
Best Practices
- Match the value to the voice - use the language or locale of the voice you synthesise with, and rely on the default when they already match
- Use the locale codes -
fr-beandfr-chread dates, numbers and amounts the way those markets expect - Disable deliberately - pass
"none"when your text is already written the way it should be spoken