> ## Documentation Index
> Fetch the complete documentation index at: https://docs.poly.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Response control

> Control how voice-agent output is filtered and pronounced before it is spoken to the user.

Response control resources process the agent's output before it is spoken.

They are used to adjust spoken output by:

* fixing pronunciation
* intercepting or blocking phrases before speech synthesis

These resources are voice-channel specific and live under `voice/response_control/`.

## Location

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
voice/response_control/
├── pronunciations.yaml
└── phrase_filtering.yaml
```

Both files are optional.

## What response control does

> [card] Pronunciations
>
> Fix how words, abbreviations, or phrases are spoken by TTS.

> [card] Phrase filtering
>
> Block or intercept phrases before they are spoken.

## Pronunciations

Pronunciation rules live in:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
voice/response_control/pronunciations.yaml
```

These rules are applied before speech synthesis and are useful when the agent says something incorrectly.

### What a pronunciation rule contains

Each item in the `pronunciations` list can include:

| Field | Required | Description |
| - | - | - |
| `regex` | Yes | Regex pattern to match in the output text |
| `replacement` | Yes | Replacement text for speech synthesis. Can be an empty string to silence the match. |
| `case_sensitive` | No | Whether matching is case-sensitive. Default: `false`. |
| `language_code` | No | Restrict the rule to a specific language. Must be a valid BCP-47 language code, for example `en-GB`. |
| `description` | No | Notes about the rule |

Rules are ordered, so list position matters.

### Example

```yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
pronunciations:
  - regex: "\\bDr\\."
    replacement: Doctor
    case_sensitive: true

  - regex: "\\bMr\\."
    replacement: Mister
    case_sensitive: true
```

## Phrase filtering

Phrase-filtering rules live in:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
voice/response_control/phrase_filtering.yaml
```

These rules can block or intercept phrases before they are spoken. A matched phrase can also trigger a function.

### What a phrase filter contains

Each item in the `phrase_filtering` list can include:

| Field | Required | Description |
| - | - | - |
| `name` | Yes | Identifier for the filter. Must be unique. |
| `description` | No | Explains what the filter does |
| `regular_expressions` | Yes | Regex patterns to match |
| `say_phrase` | No | Whether to still speak the matched phrase. Default: `false`. |
| `language_code` | No | Restrict the filter to a specific language. Must be a valid BCP-47 language code, for example `en-GB`. |
| `function` | No | Global function to call when a match occurs |

### Example

```yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
phrase_filtering:
  - name: Block Profanity
    description: Blocks profane words from being spoken
    regular_expressions:
      - "\\bbadword\\b"
    say_phrase: false

  - name: Competitor Mention Handler
    description: Intercept competitor names and redirect
    regular_expressions:
      - "\\bcompetitor_name\\b"
    say_phrase: true
    function: handle_competitor_mention
```

## When to use response control

Use response control when standard prompting is not enough and you need a more deterministic layer before output is spoken.

Typical cases include:

* fixing abbreviations or domain-specific terms in TTS
* preventing profanity from being spoken
* reducing the risk of unsafe or brand-damaging output
* intercepting special phrases and triggering code

## Best practices

### For pronunciations

* keep regex patterns targeted and readable
* use language-specific rules when pronunciation should vary by locale
* rely on rule ordering deliberately where multiple patterns could overlap

### For phrase filters

* use phrase filters for safety and brand protection
* keep regex patterns specific to avoid false positives
* only attach a `function` when you need a real side effect
* ensure the `function` value refers to a valid **global function**, not a flow function

> [!WARNING]
>
> **Phrase filters are powerful**
>
> An over-broad regex can suppress or intercept normal output unexpectedly. Keep filters as specific as possible.

## Related pages

> [card] [Voice settings](https://docs.poly.ai/adk/reference/resources/voice_settings.md)
>
> See where response control fits within the broader voice-channel configuration.

> [card] [Functions](https://docs.poly.ai/adk/reference/resources/functions.md)
>
> Learn how global functions can be triggered from phrase filters.
