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

# Pipecat

> Give a Pipecat voice agent a Finesse voice with FinesseTTSService, from the pipecat-finesse package.

`pipecat-finesse` is the Finesse text-to-speech service for [Pipecat](https://github.com/pipecat-ai/pipecat)
voice agents: a voice from the catalog or one you cloned, speaking any of 60 languages.

* **Realtime**: the agent's reply streams to Finesse as the LLM writes it, so speech starts before
  the reply is finished. All sentences of a turn share one Finesse context, so the voice keeps its
  flow across them.
* **Interruptions**: when the user talks over the agent, the turn is cancelled on the Finesse server
  and its remaining audio is dropped. The connection stays open for the next turn.
* **Any pipeline rate**: 8 kHz phone pipelines get 8 kHz audio straight from Finesse; other rates
  below Finesse's native 24 kHz, such as 16 kHz, are resampled for you.

> [card] [PyPI](https://pypi.org/project/pipecat-finesse/)
>
> `pipecat-finesse`, for Python 3.11+ and Pipecat 1.12+.

> [card] [Source on GitHub](https://github.com/homingos/pipecat-finesse)
>
> `homingos/pipecat-finesse`, BSD-2-Clause, the same as Pipecat.

## Install

```bash pip theme={null}
pip install pipecat-finesse
```

```bash uv theme={null}
uv add pipecat-finesse
```

Create an API key in the [dashboard](https://finesse.flamapp.ai/dashboard) under
**Developers → API Keys**, and put it in your agent's environment, where the service reads it:

```bash theme={null}
export FINESSE_API_KEY="flv_..."
```

Keep the key on your server. See [Authentication](https://docs.finesse.flamapp.ai/guides/authentication.md).

## Add it to your pipeline

Create a `FinesseTTSService` with the id of a `ready` voice and put it in your pipeline where any
other TTS service goes, after the LLM:

```python bot.py theme={null}
from pipecat.pipeline.pipeline import Pipeline
from pipecat.transcriptions.language import Language
from pipecat_finesse import FinesseTTSService

tts = FinesseTTSService(  # reads FINESSE_API_KEY
    settings=FinesseTTSService.Settings(
        voice="<voice-id>",
        language=Language.HI,
    ),
)

pipeline = Pipeline(
    [
        transport.input(),
        stt,
        user_aggregator,
        llm,
        tts,
        transport.output(),
        assistant_aggregator,
    ]
)
```

For a complete voice agent you can run in your browser (Deepgram, OpenAI and Finesse), see
[`examples/voice_agent.py`](https://github.com/homingos/pipecat-finesse/blob/main/examples/voice_agent.py)
in the repository.

To find a voice id, copy one from **Voices** in the dashboard, or call
[List voices](https://docs.finesse.flamapp.ai/voice-api/list-voices.md). Cloned voices work like any other. See [Voices](https://docs.finesse.flamapp.ai/concepts/voices.md).

## Settings

`FinesseTTSService.Settings` holds what can change between turns:

| Setting | Default | Description |
| - | - | - |
| `voice` | required | The id of a `ready` voice, from the catalog or one you cloned. |
| `language` | `Language.EN` | A Pipecat `Language` or a Finesse code such as `hi`, `ta` or `arz`. Region tags work: `ar-EG` is Egyptian Arabic, `ar-AE` is Gulf Arabic. |
| `num_step` | `32` | Quality versus latency, from 1 to 32. Lower is faster. |
| `guidance_scale` | `2.0` | Synthesis guidance, from 0 to 10. |
| `length_scale` | `1.0` | Speaking rate. Higher is slower. |

A change to the voice or language applies from the next turn.

The constructor also takes:

| Option | Default | Description |
| - | - | - |
| `api_key` | `FINESSE_API_KEY` | Your Finesse API key. |
| `sample_rate` | the pipeline's | Output rate in Hz. Usually left to the pipeline's `audio_out_sample_rate`. |
| `idle_flush_ms` | `800` | When the LLM pauses mid-sentence, speak the pending text after this many milliseconds. From 200 to 5000. |
| `client_name` | none | Your app's `name/version`, added to the `X-Finesse-Client` header so you can tell your apps apart in Finesse analytics. |

## Phone calls

Set the pipeline's output rate to 8 kHz and Finesse sends 8 kHz audio directly, with no resampling:

```python theme={null}
from pipecat.pipeline.task import PipelineParams

params = PipelineParams(audio_out_sample_rate=8000)
```

## Connections and limits

Each open connection holds one of your plan's concurrent streams until it closes: see
[Rate limits](https://docs.finesse.flamapp.ai/guides/rate-limits.md). A refused connection reports the HTTP status and the Finesse
error code, for example `HTTP 429 (concurrency_limited, retry after 1s)`, and the service reconnects
with backoff. The server closes a connection after 600 seconds without traffic, and the service
reopens it so the next turn doesn't wait to connect.

## Errors

| Code or status | What it means |
| - | - |
| `401` | The API key is missing, wrong, revoked or expired. |
| `voice_not_found` | The voice doesn't exist, isn't visible to your workspace, or isn't `ready` yet. The turn ends; the connection stays open. |
| `insufficient_credits` | The workspace is out of credits. Top up from **Billing** in the dashboard. |
| `429` | Over your plan's request rate or concurrent streams. Retried with backoff. |
| `503` | Finesse is briefly at capacity. Retried with backoff. |

If the connection drops mid-turn, or the server cancels a turn, the turn ends with an error instead
of going silent, and the next turn reconnects. See [Errors](https://docs.finesse.flamapp.ai/voice-api/errors.md) for every code. The
service streams over the [Realtime WebSocket](https://docs.finesse.flamapp.ai/voice-api/realtime-websocket.md), so everything there
applies.


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