# `Octoroom.Agent.TurnDetection.SmartTurn`
[🔗](https://github.com/samrat/octoroom/blob/v0.1.0/agents/lib/octoroom/agent/turn_detection/smart_turn.ex#L1)

Pipecat's Smart Turn v3 end-of-turn classifier for 16 kHz mono PCM16 audio.

Smart Turn listens to the raw waveform of the user's current turn (prosody,
intonation, fillers) and returns the probability that they have finished
speaking. It is meant to run when the VAD first reports silence: a low score
means the user is only pausing, so the agent should keep listening.

The analyzer keeps the last 8 seconds of the turn's audio. Two ONNX models do
the work and are loaded once per path, then shared between streams:

  * `smart_turn_features.onnx` turns the 8 s window into the Whisper log-mel
    spectrogram the classifier expects (bundled in `priv/models/`, built by
    `priv/models/build_smart_turn_features.py`)
  * `smart-turn-v3.2-cpu.onnx` is the int8 classifier from
    <https://huggingface.co/pipecat-ai/smart-turn-v3>, downloaded and cached
    on demand via `Octoroom.Agent.Models` (or pre-fetched with
    `mix octoroom.models.download`)

# `t`

```elixir
@type t() :: %Octoroom.Agent.TurnDetection.SmartTurn{
  buffer: term(),
  features: term(),
  model: term()
}
```

# `append`

```elixir
@spec append(t(), binary()) :: t()
```

Appends PCM16 audio, keeping only the most recent 8 seconds.

# `buffered_ms`

```elixir
@spec buffered_ms(t()) :: non_neg_integer()
```

Buffered audio duration in milliseconds.

# `default_features_model_path`

# `default_model_path`

# `keep_last_ms`

```elixir
@spec keep_last_ms(t(), non_neg_integer()) :: t()
```

Drops all but the most recent `ms` of audio.

# `new`

```elixir
@spec new(keyword()) :: {:ok, t()} | {:error, term()}
```

Loads (or reuses) the ONNX models and returns an analyzer with no audio.

When `:model_path` is not given, `Octoroom.Agent.Models.ensure(:smart_turn, opts)`
resolves (and downloads if missing) `smart-turn-v3.2-cpu.onnx`.

# `predict`

```elixir
@spec predict(t()) :: float()
```

Returns the probability (0.0 to 1.0) that the buffered turn is complete.

# `reset`

```elixir
@spec reset(t()) :: t()
```

Clears buffered audio.

# `sample_rate`

# `window_ms`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
