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

Voice activity state machine.

Turns a stream of per-frame speech probabilities (from `Octoroom.Agent.VAD.Silero`
or any other analyzer) into `:speech_started` / `:speech_stopped` events using
hysteresis:

  * speech starts once probabilities stay at or above `start_threshold` for
    `min_speech_ms`
  * speech stops once probabilities stay below `stop_threshold` for
    `min_silence_ms`

Probabilities between the two thresholds keep the current state.

# `event`

```elixir
@type event() :: :speech_started | :speech_stopped
```

# `t`

```elixir
@type t() :: %Octoroom.Agent.VAD{
  frame_ms: term(),
  min_silence_ms: term(),
  min_speech_ms: term(),
  run_ms: term(),
  speaking?: term(),
  start_threshold: term(),
  stop_threshold: term()
}
```

# `defaults`

# `new`

Builds a state machine. Accepts a map or keyword list with any of the default
keys plus `:frame_ms` (the duration covered by each probability).

# `process`

```elixir
@spec process(t(), number()) :: {[event()], t()}
```

Feeds one frame probability. Returns the events it triggered.

# `process_all`

```elixir
@spec process_all(t(), [number()]) :: {[event()], t()}
```

Feeds several frame probabilities in order.

---

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