Octoroom.Agent.VAD (octoroom_agents v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

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

Feeds one frame probability. Returns the events it triggered.

Feeds several frame probabilities in order.

Types

event()

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

t()

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

Functions

defaults()

new(opts \\ %{})

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(vad, probability)

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

Feeds one frame probability. Returns the events it triggered.

process_all(vad, probabilities)

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

Feeds several frame probabilities in order.