Octoroom.Agent.TurnDetection.SmartTurn (octoroom_agents v0.1.0)

Copy Markdown View Source

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:

Summary

Functions

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

Buffered audio duration in milliseconds.

Drops all but the most recent ms of audio.

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

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

Clears buffered audio.

Types

t()

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

Functions

append(smart_turn, pcm)

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

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

buffered_ms(smart_turn)

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

Buffered audio duration in milliseconds.

default_features_model_path()

default_model_path()

keep_last_ms(smart_turn, ms)

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

Drops all but the most recent ms of audio.

new(opts \\ [])

@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(smart_turn)

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

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

reset(smart_turn)

@spec reset(t()) :: t()

Clears buffered audio.

sample_rate()

window_ms()