# Pipecat Integration

Pipecat is an open-source framework for building real-time voice and multimodal AI agents. The Pinch Pipecat plugin allows developers to add real-time voice translation directly into Pipecat pipelines.

## Prerequisites

Before using the Pinch Pipecat plugin, ensure you have:

- Python 3.10+
- A Pinch API key
- Pipecat installed

You can generate an API key from the [Pinch Developer Portal >](https://portal.startpinch.com/dashboard/developers)

## Installation

Install the Pinch Pipecat plugin (installs the required dependencies):

```bash
pip install pipecat-plugins-pinch
```

If you plan to run the Daily transport example:

```bash
pip install "pipecat-ai[daily]" python-dotenv
```

## Usage

The following example adds Pinch translation to a Pipecat pipeline.

```python
from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.runner import PipelineRunner

from pipecat.plugins.pinch import PinchTranslatorService, TranslatorOptions

translator = PinchTranslatorService(
    options=TranslatorOptions(
        source_language="en-US",
        target_language="es-ES"
    )
)

pipeline = Pipeline([
    translator
])

runner = PipelineRunner()
runner.run(pipeline)
```

This pipeline receives speech in English and outputs translated speech in Spanish.

## Running the Example

The git repository includes a working example that demonstrates real-time translation using the Daily transport.

Install required dependencies:

```bash
pip install "pipecat-ai[daily]" python-dotenv
```

Run the example:

```bash
python examples/daily_basic.py
```

## Translator Configuration

The `TranslatorOptions` class allows you to configure translation behavior.

| Option             | Description                             |
| ------------------ | --------------------------------------- |
| `source_language`  | Language of the incoming speech         |
| `target_language`  | Language to translate into              |
| `voice_type`       | Output voice mode (e.g. cloned voice)  |

Example configuration:

```python
TranslatorOptions(
    source_language="en-US",
    target_language="fr-FR",
    voice_type="clone"
)
```

## Learn More

- [Pinch Pipecat Repo](https://github.com/pinch-eng/pipecat-plugins-pinch)
- [Pipecat Framework](https://github.com/pipecat-ai/pipecat)
- [Pinch Python SDK](https://pypi.org/project/pinch-sdk/)
