> ## 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.

# Turn Blend

> Local end-of-turn detection that blends Smart Turn v3.2 and turn-1-mini scores in one CPU-only ONNX model, with no API key

> [!NOTE]
>
> **Community-maintained integration.** This service is built and
> maintained by
> [adhiraj4802](https://github.com/adhiraj4802)
> . Pipecat does not test or officially support it. Please report issues and
> request changes on the
> [source repository](https://github.com/adhiraj4802/pipecat-turn-blend)
> . Learn more about
> [community integrations](https://docs.pipecat.ai/api-reference/server/services/community-integrations.md)
> .

## Overview

`TurnBlendAnalyzer` is a turn analyzer backed by `turn-blend.onnx`, a single 56 MB model file that contains
Silero VAD v6.2, [Smart Turn v3.2](https://github.com/pipecat-ai/smart-turn), p99lab's
[turn-1-mini](https://huggingface.co/p99lab/turn-1-mini) and a logistic blend of the two end-of-turn scores
with the elapsed silence. It runs locally on the CPU, needs no API key or GPU, and decides from audio alone.

On LiveKit's [eot-bench](https://github.com/livekit/eot-bench) (English, 400 turns, cross-validated) the blend
makes fewer false cut-offs than either model inside it: 20.1% at a 300 ms latency budget, against 22.6% for
turn-1-mini and 35.2% for Smart Turn v3.2. It is behind the best hosted models. The blend's weights were fitted
on that same dataset, so expect a smaller gain on other audio; the
[benchmark page](https://github.com/adhiraj4802/pipecat-turn-blend/blob/main/benchmark/README.md) has the full
tables, the latency measurements and the limits.

> [!NOTE]
>
> English only, because turn-1-mini is English only. For other languages use
> Pipecat's built-in Smart Turn.

> [card] [Source Repository](https://github.com/adhiraj4802/pipecat-turn-blend)
>
> Source code, example bot, and issues for the Turn Blend integration

> [card] [Benchmarks](https://github.com/adhiraj4802/pipecat-turn-blend/blob/main/benchmark/README.md)
>
> eot-bench results and CPU latency measurements

## Installation

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

```bash theme={null}
uv pip install git+https://github.com/adhiraj4802/pipecat-turn-blend.git
```

## Prerequisites

* **Pipecat 1.0 or later** (tested with `pipecat-ai` 1.16.0)
* **16 kHz input audio**: set `PipelineParams(audio_in_sample_rate=16000)`
* **2 or more CPU threads** for the model to keep up in real time

No account, API key or environment variable is required. The model is downloaded from the repository's releases
on first use, checked against its SHA-256 and cached in `~/.cache/turn-blend`.

The plugin code and blend are Apache-2.0. The model file also contains the unmodified weights of Silero VAD
(MIT), Smart Turn v3.2 (BSD 2-Clause) and turn-1-mini (Apache-2.0); all of those licences apply to it.

## Usage

```python theme={null}
from pipecat.audio.vad.silero import SileroVADAnalyzer
from pipecat.pipeline.worker import PipelineParams, PipelineWorker
from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair, LLMUserAggregatorParams
from pipecat.turns.user_stop import TurnAnalyzerUserTurnStopStrategy
from pipecat.turns.user_turn_strategies import UserTurnStrategies
from pipecat_turn_blend import TurnBlendAnalyzer

turn = TurnBlendAnalyzer(
    blend_threshold=0.85,                 # any model setting can be passed as a keyword
    on_end_of_turn=lambda r: print(r),    # {"reason": "commit", "silence_ms": 384, "detect_ms": 416, ...}
)

aggregators = LLMContextAggregatorPair(context, user_params=LLMUserAggregatorParams(
    vad_analyzer=SileroVADAnalyzer(),
    user_turn_strategies=UserTurnStrategies(stop=[TurnAnalyzerUserTurnStopStrategy(turn_analyzer=turn)]),
))

worker = PipelineWorker(pipeline, params=PipelineParams(audio_in_sample_rate=16000))
```

Pipecat's VAD still opens the user turn and handles interruptions. The analyzer ends the turn when the blend
commits, or when the silence timeout runs out.

## Configuration

**model\_path** `str` (default: None)

Path to `turn-blend.onnx`. If omitted, the model is downloaded on first use.

**threads** `int` (default: 4)

CPU threads for the model.

**on\_end\_of\_turn** `Callable` (default: None)

Callback with the result of each ended turn: the reason (`commit` or
`timeout`), the silence waited, the detection delay and the three scores. The
same dict is kept in `last_result`.

**blend\_threshold** `float` (default: 0.85)

The turn ends when the blended probability is above this.

**blend\_min\_silence\_ms** `float` (default: 320)

Silence required before the blend may end the turn.

**blend\_confirm\_scores** `float` (default: 2)

Number of consecutive scores above the threshold required.

**timeout\_secs** `float` (default: 3.0)

Silence that ends the turn even if the blend never commits.

The model has 16 settings in all, including its VAD thresholds and the blend weights. Each can be passed as a
keyword argument, changed later with `turn.detector.configure(...)`, or read from a JSON file and
`TURN_BLEND_<SETTING>` environment variables with `load_settings()`. The
[README](https://github.com/adhiraj4802/pipecat-turn-blend#settings) lists them.

## Compatibility

Last tested with Pipecat v1.16.0.


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