> ## Documentation Index
> Fetch the complete documentation index at: https://daily-docs-deploy-no-op-warm-pods-t3002.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SonexLabs Text-to-Speech

> SonexTTSService converts text to speech with SonexLabs' streaming TTS API.

export const CommunityMaintained = ({maintainer, maintainerUrl, repo}) => <Note>
    <strong>Community-maintained integration.</strong> This service is built and
    maintained by{" "}
    <a href={maintainerUrl} target="_blank" rel="noreferrer">
      {maintainer}
    </a>
    . Pipecat does not test or officially support it. Please report issues and
    request changes on the{" "}
    <a href={repo} target="_blank" rel="noreferrer">
      source repository
    </a>
    . Learn more about{" "}
    <a href="/api-reference/server/services/community-integrations">
      community integrations
    </a>
    .
  </Note>;

<CommunityMaintained maintainer="ayushi-agarwall" maintainerUrl="https://github.com/ayushi-agarwall" repo="https://github.com/sonexlabs/pipecat-sonex" />

## Overview

`SonexTTSService` converts text into speech using [SonexLabs'](https://sonexlabs.com)
streaming text-to-speech API. It streams audio over HTTP with connection
keep-alive for low time-to-first-audio, and supports multiple voices and
languages, with automatic language detection when none is specified.

<CardGroup cols={2}>
  <Card title="Source Repository" icon="github" href="https://github.com/sonexlabs/pipecat-sonex">
    Source code, examples, and issues for the SonexLabs integration
  </Card>

  <Card title="SonexLabs" icon="book" href="https://sonexlabs.com">
    Learn more about SonexLabs' text-to-speech service
  </Card>
</CardGroup>

## Installation

This is a community-maintained package distributed separately from `pipecat-ai`:

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

## Prerequisites

### SonexLabs Account Setup

Before using the SonexLabs text-to-speech service, you need:

1. **SonexLabs Account**: Sign up at [SonexLabs](https://sonexlabs.com)
2. **API Key**: Generate an API key from your account dashboard
3. **Voice Selection**: Pick a voice ID from your account's available voices

### Required Environment Variables

* `SONEX_API_KEY`: Your SonexLabs API key for authentication

## Configuration

<ParamField path="api_key" type="str" required>
  SonexLabs API key.
</ParamField>

<ParamField path="voice" type="str" required>
  Voice ID to use for synthesis.
</ParamField>

<ParamField path="language" type="str" default="None">
  Optional language override. Leave unset to auto-detect from the input text.
</ParamField>

<ParamField path="settings" type="SonexTTSService.Settings" default="None">
  Runtime-configurable settings, such as `speed`.
</ParamField>

## Usage

```python theme={null}
from pipecat_sonex import SonexTTSService

tts = SonexTTSService(
    api_key=os.getenv("SONEX_API_KEY"),
    voice=os.getenv("SONEX_VOICE_ID"),
)

pipeline = Pipeline([
    transport.input(),
    stt,
    context_aggregator.user(),
    llm,
    tts,
    transport.output(),
    context_aggregator.assistant(),
])
```

## Compatibility

Tested with Pipecat v1.7.0.
