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

# Transformation

> Rewrite the text stream before it's spoken (fix pronunciation, filter content, or normalize formatting) with a pipeline hook.

Sometimes the LLM's text needs a touch-up before it's spoken: expand an acronym so TTS says it
correctly, strip markdown, or filter sensitive content. The `tts` [pipeline hook](/build/configure-a-pipeline/runtime-hooks)
gives you the reply's text stream so you can transform it before synthesis.

## The `tts` hook

Register an async hook with `@pipeline.on("tts")`. It receives the streaming reply
text; yield the transformed text, then hand it to `run_tts()` to produce the audio.

<CodeGroup>
  ```python title="main.py" Python theme={null}
  import re
  from zrt import run_tts

  pronunciation_map = {"nginx": "engine x", "API": "A P I", "SQL": "sequel"}

  @pipeline.on("tts")
  async def tts_node(text_stream):
      async def text_phase():
          async for response in text_stream:
              processed = response
              for word, say_as in pronunciation_map.items():
                  processed = re.sub(rf"\b{word}\b", say_as, processed, flags=re.IGNORECASE)
              yield processed

      async for audio_chunk in run_tts(text_phase()):
          yield audio_chunk
  ```
</CodeGroup>

## What you can do in the hook

* **Fix pronunciation** of acronyms, brand names, and technical terms (shown above).
* **Filter or redact** content before it's spoken.
* **Normalize formatting**: strip markdown, expand numbers/dates, clean up symbols.

Because the hook sits between the LLM and TTS, the change affects only what's *spoken*: the
text recorded in [chat context](/build/context-management/access-context) is unchanged.

<Tip>
  This is one of several [pipeline hooks](/build/configure-a-pipeline/runtime-hooks). The same
  mechanism lets you intercept other stages of the pipeline.
</Tip>

## References

<Tabs>
  <Tab title="Python">
    #### Examples

    <CardGroup cols={2}>
      <Card title="Enhanced Pronunciation" icon="github" href="https://github.com/ZeroRuntimeAI/zrt-python-sdk-examples/blob/main/features/pronunciation.py">
        Rewrite text before synthesis.
      </Card>
    </CardGroup>
  </Tab>
</Tabs>
