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

# Rime Text-to-Speech

> TTS with RimeTTSService and RimeV1TTSService (WebSocket streaming with interruptions) and RimeHttpTTSService for batch synthesis.

## Overview

Rime AI provides three TTS service implementations: `RimeTTSService` (WebSocket-based) with word-level timing and interruption support, `RimeV1TTSService` (WebSocket v1 API) with interruption support and no word timing, and `RimeHttpTTSService` (HTTP-based) for simpler use cases. `RimeTTSService` and `RimeV1TTSService` are recommended for real-time interactive applications.

> [card] [Rime TTS API Reference](https://reference-server.pipecat.ai/en/latest/api/pipecat.services.rime.tts.html)
>
> Pipecat's API methods for Rime TTS integration

> [card] [Example Implementation](https://github.com/pipecat-ai/pipecat/blob/main/examples/voice/voice-rime.py)
>
> Complete example with word timestamps

> [card] [Rime Documentation](https://docs.rime.ai/api-reference/coda/websockets-json)
>
> Official Rime WebSocket and HTTP API documentation

> [card] [Voice Models](https://docs.rime.ai/)
>
> Explore available voice models and features

## Installation

To use Rime services, install the required dependencies:

```bash theme={null}
uv add "pipecat-ai[rime]"
```

## Prerequisites

### Rime Account Setup

Before using Rime TTS services, you need:

1. **Rime Account**: Sign up at [Rime AI](https://docs.rime.ai/)
2. **API Key**: Generate an API key from your account dashboard
3. **Voice Selection**: Choose from available voice models

### Required Environment Variables

* `RIME_API_KEY`: Your Rime API key for authentication

## Configuration

### RimeTTSService

**api\_key** `str` *required*

Rime API key for authentication.

**voice\_id** `str` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=RimeTTSService.Settings(voice=...)` instead.

**url** `str` (default: wss\://users-ws.rime.ai/ws3)

Rime WebSocket API endpoint.

**model** `str` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=RimeTTSService.Settings(model=...)` instead.

**sample\_rate** `int` (default: None)

Output audio sample rate in Hz. When `None`, uses the pipeline's configured
sample rate.

**text\_aggregation\_mode** `TextAggregationMode` (default: None)

Controls how incoming text is aggregated before synthesis. `SENTENCE` (used
when `None`) buffers text until sentence boundaries, producing more natural
speech. `TOKEN` streams tokens directly for lower latency. Import from
`pipecat.services.tts_service`.

**aggregate\_sentences** `bool` *deprecated* (default: None)

*Deprecated since 0.0.104, removed in 2.0.0.* Use `text_aggregation_mode`
instead.

**params** `InputParams` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=RimeTTSService.Settings(...)` instead.

**settings** `RimeTTSService.Settings` (default: None)

Runtime-configurable settings. See [RimeTTSService
Settings](#rimettsservice-settings) below.

### RimeHttpTTSService

**api\_key** `str` *required*

Rime API key for authentication.

**voice\_id** `str` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=RimeHttpTTSService.Settings(voice=...)` instead.

**aiohttp\_session** `aiohttp.ClientSession` *required*

An aiohttp session for HTTP requests.

**model** `str` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=RimeHttpTTSService.Settings(model=...)` instead.

**sample\_rate** `int` (default: None)

Output audio sample rate in Hz. When `None`, uses the pipeline's configured
sample rate.

**params** `InputParams` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=RimeHttpTTSService.Settings(...)` instead.

**settings** `RimeHttpTTSService.Settings` (default: None)

Runtime-configurable settings. See [RimeTTSService
Settings](#rimettsservice-settings) below; the HTTP service defaults
`language` to `"eng"`.

### RimeV1TTSService

**api\_key** `str` *required*

Rime API key for authentication.

**websocket\_url** `str | None` (default: None)

Rime WebSocket v1 endpoint override. When `None`, the public endpoint for
`settings.model` is used: `wss://coda.api.rime.ai/ws` for `coda` and
`wss://mist.api.rime.ai/ws` for `mistv3`. The model is not inferred from the
URL, and a custom URL can use any path. Must be an absolute `ws` or `wss` URL.
Required for models other than `coda` and `mistv3`. Raises `ValueError` when
the URL is not an absolute `ws` or `wss` URL, or when a model without a public
endpoint is used with no URL.

**websocket\_protocol** `Literal["binary", "json"]` (default: "binary")

Encoding of the protobuf messages exchanged with Rime. Raises `ValueError` for
any other value.

**sample\_rate** `int | None` (default: None)

Output audio sample rate in Hz. When `None`, uses the pipeline's configured
sample rate.

**text\_aggregation\_mode** `TextAggregationMode | None` (default: None)

Controls how incoming text is aggregated before synthesis. `SENTENCE` (used
when `None`) sends whole sentences. `TOKEN` sends LLM tokens as they arrive,
and Rime accumulates them into sentences. Import from
`pipecat.services.tts_service`.

**settings** `RimeV1TTSService.Settings` *required*

Settings with an explicit `model` (raises `ValueError` if missing). Other
fields are runtime-configurable; changing `model` later does not switch
endpoints. See [RimeV1TTSService Settings](#rimev1ttsservice-settings) below.

### RimeNonJsonTTSService

*Deprecated since 0.0.102, removed in 2.0.0.* A non-JSON WebSocket service that uses plain-text
messages and raw audio responses. Use `RimeTTSService` instead.

**api\_key** `str` *required*

Rime API key for authentication.

**voice\_id** `str` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=RimeNonJsonTTSService.Settings(voice=...)` instead.

**url** `str` (default: wss\://users.rime.ai/ws)

Rime WebSocket API endpoint.

**model** `str` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=RimeNonJsonTTSService.Settings(model=...)` instead.

**audio\_format** `str` (default: pcm)

Audio output format.

**sample\_rate** `int` (default: None)

Output audio sample rate in Hz. When `None`, uses the pipeline's configured
sample rate.

**text\_aggregation\_mode** `TextAggregationMode` (default: None)

Controls how incoming text is aggregated before synthesis. `SENTENCE` (used
when `None`) buffers text until sentence boundaries. `TOKEN` streams tokens
directly for lower latency. Import from `pipecat.services.tts_service`.

**aggregate\_sentences** `bool` *deprecated* (default: None)

*Deprecated since 0.0.104, removed in 2.0.0.* Use `text_aggregation_mode`
instead.

**params** `InputParams` *deprecated* (default: None)

*Deprecated since 0.0.105, removed in 2.0.0.* Use
`settings=RimeNonJsonTTSService.Settings(...)` instead.

**settings** `RimeNonJsonTTSService.Settings` (default: None)

Runtime-configurable settings. See [RimeNonJsonTTSService
Settings](#rimenonjsonttsservice-settings) below.

#### RimeTTSService Settings

Runtime-configurable settings passed via the `settings` constructor argument using `RimeTTSService.Settings(...)`. These can be updated mid-conversation with `TTSUpdateSettingsFrame`. See [Service Settings](https://docs.pipecat.ai/pipecat/fundamentals/service-settings.md) for details.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | `str` | `"coda"` | Model identifier. *(Inherited.)* |
| `voice` | `str` | `None` | Voice identifier. *(Inherited.)* |
| `language` | `Language \| str` | `None` | Language for synthesis. *(Inherited.)* |
| `segment` | `str` | `None` | Segment type for synthesis. |
| `speedAlpha` | `float` | `None` | Speed alpha parameter. |
| `reduceLatency` | `bool` | `None` | Whether to reduce latency. Sent only when `model` is not `"coda"`. |
| `pauseBetweenBrackets` | `bool` | `None` | Pause between brackets. Sent only when `model` is not `"coda"`. |
| `phonemizeBetweenBrackets` | `bool` | `None` | Phonemize between brackets. Sent only when `model` is not `"coda"`. |
| `noTextNormalization` | `bool` | `None` | Disable text normalization. Sent only when `model` is not `"coda"`. |
| `saveOovs` | `bool` | `None` | Save out-of-vocabulary words. Sent only by `RimeTTSService`, and only when `model` is not `"coda"`. |
| `inlineSpeedAlpha` | `str` | `None` | Inline speed alpha. Sent only by `RimeHttpTTSService`. With `RimeTTSService`, use `INLINE_SPEED()` instead. |
| `repetition_penalty` | `float` | `None` | Token repetition penalty (coda only, 1.0-2.0). |
| `temperature` | `float` | `None` | Sampling temperature (coda only, 0.0-1.0). |
| `top_p` | `float` | `None` | Cumulative probability threshold (coda only, 0.0-1.0). |
| `timeScaleFactor` | `float` | `None` | Audio playback speed factor (coda only). Values above 1.0 slow down the audio; values below 1.0 speed it up. |

#### RimeV1TTSService Settings

Runtime-configurable settings passed via the `settings` constructor argument using `RimeV1TTSService.Settings(...)`. These can be updated mid-conversation with `TTSUpdateSettingsFrame`, and each synthesis context uses the settings in effect when it starts. See [Service Settings](https://docs.pipecat.ai/pipecat/fundamentals/service-settings.md) for details.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | `str` | Required | Model identifier, such as `"coda"` or `"mistv3"`. Selects the public endpoint unless `websocket_url` is set. *(Inherited.)* |
| `voice` | `str` | `None` | Voice identifier, also accepted as `speaker`. *(Inherited.)* |
| `language` | `Language \| str` | `None` | Language for synthesis, sent as a base language tag such as `"en"`. *(Inherited.)* |
| `time_scale_factor` | `float` | `None` | Audio playback speed factor. Values above 1.0 slow down the audio; values below 1.0 speed it up. Not applied for `mistv2`. |
| `text_lookahead_tokens` | `int` | `None` | Number of input tokens to collect before audio starts. Applied only for `coda`. |
| `pause_between_brackets` | `bool` | `None` | Pause between brackets. Applied only for Mist models. |
| `phonemize_between_brackets` | `bool` | `None` | Phonemize bracketed content. Applied only for Mist models. |
| `save_oovs` | `bool` | `None` | Save out-of-vocabulary words. Applied only for Mist models. |

A setting the model does not accept is left out of the request and logs a warning. `None` leaves a setting unsent, so Rime's default applies.

#### RimeNonJsonTTSService Settings

Runtime-configurable settings passed via the `settings` constructor argument using `RimeNonJsonTTSService.Settings(...)`. These can be updated mid-conversation with `TTSUpdateSettingsFrame`. See [Service Settings](https://docs.pipecat.ai/pipecat/fundamentals/service-settings.md) for details.

| Parameter | Type | Default | Description |
| - | - | - | - |
| `model` | `str` | `"coda"` | Model identifier. *(Inherited.)* |
| `voice` | `str` | `None` | Voice identifier. *(Inherited.)* |
| `language` | `Language \| str` | `None` | Language for synthesis. *(Inherited.)* |
| `segment` | `str` | `None` | Segment type for synthesis. |
| `repetition_penalty` | `float` | `None` | Token repetition penalty. |
| `temperature` | `float` | `None` | Sampling temperature. |
| `top_p` | `float` | `None` | Cumulative probability threshold. |

## Usage

### Basic Setup (WebSocket)

```python theme={null}
import os

from pipecat.services.rime.tts import RimeTTSService

tts = RimeTTSService(
    api_key=os.getenv("RIME_API_KEY"),
    settings=RimeTTSService.Settings(
        model="coda",
        voice="luna",
    ),
)
```

### With Customization (WebSocket)

```python theme={null}
from pipecat.services.rime.tts import RimeTTSService
from pipecat.transcriptions.language import Language

tts = RimeTTSService(
    api_key=os.getenv("RIME_API_KEY"),
    settings=RimeTTSService.Settings(
        voice="cove",
        model="mistv2",
        language=Language.ES,
        speedAlpha=1.2,
        reduceLatency=True,
    ),
)
```

### WebSocket v1 Service

```python theme={null}
from pipecat.services.rime.tts_v1 import RimeV1TTSService

tts = RimeV1TTSService(
    api_key=os.getenv("RIME_API_KEY"),
    settings=RimeV1TTSService.Settings(
        model="coda",
        voice="luna",
        text_lookahead_tokens=4,
    ),
)
```

### HTTP Service

```python theme={null}
import aiohttp
from pipecat.services.rime.tts import RimeHttpTTSService

async with aiohttp.ClientSession() as session:
    tts = RimeHttpTTSService(
        api_key=os.getenv("RIME_API_KEY"),
        settings=RimeHttpTTSService.Settings(
            model="coda",
            voice="luna",
        ),
        aiohttp_session=session,
    )
```

## Customizing Speech

`RimeTTSService` provides a set of helper methods for implementing Rime-specific customizations, meant to be used as part of text transformers. These include methods for spelling out text, inserting pauses, setting custom pronunciations, and adjusting speech rate. See the [Text Transformers for TTS](https://docs.pipecat.ai/pipecat/learn/text-to-speech.md#text-transforms) section in the Text-to-Speech guide for usage examples.

### RimeTTSService.SPELL(text: str) -> str

Static method that implements [Rime's spell function](https://docs.rime.ai/api-reference/spell) to spell out text character by character. Call this method on the class, not on an instance. `RimeV1TTSService.SPELL()` works the same way.

```python theme={null}
# Text transformers for TTS
# This will insert Rime's spell tags around the provided text.
async def spell_out_text(text: str, type: str) -> str:
    return RimeTTSService.SPELL(text)

tts = RimeTTSService(
    api_key=os.getenv("RIME_API_KEY"),
    text_transforms=[
        ("phone_number", spell_out_text),
    ],
)
```

### RimeTTSService.PAUSE\_TAG(seconds: float) -> str

Static method that implements [Rime's custom pause functionality](https://docs.rime.ai/api-reference/custom-pauses) to generate a properly formatted pause tag you can insert into the text. Call this method on the class, not on an instance. `RimeV1TTSService.PAUSE_TAG()` works the same way.

```python theme={null}
# Text transformers for TTS
# This will insert a one second pause after questions.
async def pause_after_questions(text: str, type: str) -> str:
    if text.endswith("?"):
        return f"{text}{RimeTTSService.PAUSE_TAG(1.0)}"
    return text

tts = RimeTTSService(
    api_key=os.getenv("RIME_API_KEY"),
    text_transforms=[
        ("sentence", pause_after_questions), # Only apply to sentence aggregations
    ],
)
```

### PRONOUNCE(self, text: str, word: str, phoneme: str) -> str:

Convenience method to support Rime's [custom pronunciations feature](https://docs.rime.ai/api-reference/custom-pronunciation). It returns the text with every occurrence of `word` replaced by `phoneme` wrapped in curly braces, and turns on `phonemizeBetweenBrackets` for the next message. Pass the phoneme string without braces. Call it on the service instance, not on the class.

```python theme={null}
# Text transformers for TTS
# This puts a phoneme string in place of the word "potato" to define how
# it should be pronounced.
async def maybe_say_potato_all_fancylike(text: str, type: str) -> str:
    if using_fancy_voice:
        return tts.PRONOUNCE(text, "potato", "p0xt1at0o")  # po-TAH-to
    else:
        return tts.PRONOUNCE(text, "potato", "p0xt1et0o")  # po-TAY-to

tts = RimeTTSService(
    api_key=os.getenv("RIME_API_KEY"),
    # Coda doesn't support custom pronunciations
    settings=RimeTTSService.Settings(model="mistv3"),
    text_transforms=[
        ("*", maybe_say_potato_all_fancylike), # Apply to all text
    ],
)
```

### INLINE\_SPEED(self, text: str, speed: float) -> str:

A convenience method to support Rime's [inline speed adjustment feature](https://docs.rime.ai/api-reference/speed). It wraps the provided text in `[]` and appends the provided speed to the `inlineSpeedAlpha` field of the next message. Call it on the service instance, not on the class.

```python theme={null}
# Text transformers for TTS
# This will make the word slow always be spoken more slowly.
async def slow_down_slow_words(text: str, type: str) -> str:
    return text.replace(
        "slow",
        tts.INLINE_SPEED("slow", speed=0.5)
    )

tts = RimeTTSService(
    api_key=os.getenv("RIME_API_KEY"),
    text_transforms=[
        ("*", slow_down_slow_words), # Apply to all text
    ],
)
```

## Notes

* **Word-level timestamps**: `RimeTTSService` provides word-level timing information, enabling synchronized text highlighting.
* **WebSocket vs HTTP**: The WebSocket service supports word-level timestamps, interruption handling, and maintains context across messages within a turn. The HTTP service is simpler but lacks these features.
* **WebSocket v1**: `RimeV1TTSService` does not provide word-level timestamps. Interruptions cancel the current synthesis context without reconnecting.
* **Non-JSON WebSocket**: `RimeNonJsonTTSService` is the deprecated plain-text and raw-audio WebSocket implementation. It does not support word-level timestamps.

## Event Handlers

Rime WebSocket TTS services support the standard [service connection events](https://docs.pipecat.ai/api-reference/server/events/service-events.md):

| Event | Description |
| - | - |
| `on_connected` | Connected to Rime WebSocket |
| `on_disconnected` | Disconnected from Rime WebSocket |
| `on_connection_error` | WebSocket connection error occurred |

```python theme={null}
@tts.event_handler("on_connected")
async def on_connected(service):
    print("Connected to Rime")
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.