tts_v1

Rime WebSocket v1 text-to-speech service implementation.

pipecat.services.rime.tts_v1.language_to_rime_v1_language(language: Language) → str[source]

Convert a pipecat Language to the BCP-47 tag Rime WebSocket v1 expects.

Parameters:

language – The pipecat Language enum value.

Returns:

The base BCP-47 tag (e.g., ‘en’ for English). A region-qualified language falls back to its base tag.

class pipecat.services.rime.tts_v1.RimeV1TTSSettings(model: str | None | NotGiven = <factory>, extra: dict[str, Any]=<factory>, voice: str | None | NotGiven = <factory>, language: Language | str | None | NotGiven = <factory>, time_scale_factor: float | None | NotGiven = <factory>, text_lookahead_tokens: int | None | NotGiven = <factory>, pause_between_brackets: bool | None | NotGiven = <factory>, phonemize_between_brackets: bool | None | NotGiven = <factory>, save_oovs: bool | None | NotGiven = <factory>)[source]

Bases: TTSSettings

Settings for RimeV1TTSService.

Each context uses the settings in effect when it starts.

Parameters:
  • model – Required at construction. "coda" and "mistv3" select their public endpoints unless websocket_url is provided.

  • time_scale_factor – Audio playback speed factor. Values above 1.0 slow down the audio; values below 1.0 speed it up. Not supported by mistv2.

  • text_lookahead_tokens – Number of input tokens to collect before audio starts (Coda only).

  • pause_between_brackets – Whether to add pauses between bracketed content (Mist only).

  • phonemize_between_brackets – Whether to phonemize bracketed content (Mist only).

  • save_oovs – Whether to save out-of-vocabulary words (Mist only).

class pipecat.services.rime.tts_v1.RimeV1TTSService(*, api_key: str, websocket_url: str | None = None, websocket_protocol: Literal['binary', 'json'] = 'binary', sample_rate: int | None = None, text_aggregation_mode: TextAggregationMode | None = None, settings: RimeV1TTSSettings | None = None, **kwargs)[source]

Bases: WebsocketTTSService

Text-to-Speech service using Rime’s WebSocket v1 API.

Sends protobuf envelopes, in binary or proto3 JSON encoding, over one connection that carries a synthesis context per Pipecat turn. Interruptions cancel the turn’s context without reconnecting. Text is sent as whole sentences by default; with TextAggregationMode.TOKEN, LLM tokens are sent as they arrive and Rime accumulates them into sentences. settings.model is required and selects the public endpoint at construction: "coda" uses wss://coda.api.rime.ai/ws and "mistv3" uses wss://mist.api.rime.ai/ws. Pass websocket_url to use a custom deployment. The model is not inferred from the URL hostname or path. A context leaves out, with a warning, any setting its model does not accept. WebSocket v1 does not report word timestamps.

Requires the rime extra: uv add "pipecat-ai[rime]".

Settings

alias of RimeV1TTSSettings

__init__(*, api_key: str, websocket_url: str | None = None, websocket_protocol: Literal['binary', 'json'] = 'binary', sample_rate: int | None = None, text_aggregation_mode: TextAggregationMode | None = None, settings: RimeV1TTSSettings | None = None, **kwargs)[source]

Initialize the Rime WebSocket v1 TTS service.

Parameters:
  • api_key – Rime API key for authentication.

  • websocket_url – Rime WebSocket v1 endpoint override. Defaults to the public endpoint for settings.model. Custom URLs can use any path. Models without a public default require an explicit URL.

  • websocket_protocol – Envelope encoding, "binary" or "json".

  • sample_rate – Audio sample rate in Hz.

  • text_aggregation_mode – How to aggregate text before synthesis. Defaults to TextAggregationMode.SENTENCE. TextAggregationMode.TOKEN streams LLM tokens and has Rime accumulate them into sentences.

  • settings – Settings with an explicit model. Other fields can be updated at runtime; changing model does not switch endpoints.

  • **kwargs – Additional arguments passed to parent class.

can_generate_metrics() → bool[source]

Check if this service can generate processing metrics.

Returns:

True, as Rime service supports metrics generation.

language_to_service_language(language: Language) → str | None[source]

Convert pipecat language to the BCP-47 tag Rime WebSocket v1 expects.

Parameters:

language – The language to convert.

Returns:

The BCP-47 language tag.

static SPELL(text: str) → str[source]

Wrap text in Rime spell function.

static PAUSE_TAG(seconds: float) → str[source]

Convenience method to create a pause tag.

async setup(setup: FrameProcessorSetup)[source]

Set up the service and connect.

Parameters:

setup – Configuration object containing setup parameters.

async on_audio_context_interrupted(context_id: str)[source]

Cancel the Rime context when the bot is interrupted.

async on_turn_context_completed()[source]

Close a failed context’s audio once its turn has no more text.

async flush_audio(context_id: str | None = None)[source]

End the context’s input so Rime synthesizes the rest of its text.

Parameters:

context_id – The specific context to flush. If None, falls back to the currently active context.

async run_tts(text: str, context_id: str) → AsyncGenerator[Frame | None, None][source]

Generate speech from text using Rime’s WebSocket v1 API.

Parameters:
  • text – The text to synthesize into speech.

  • context_id – The context ID for tracking audio frames.

Yields:

Frame – Audio frames containing the synthesized speech.