n3d_stream: Streaming Diarization

View source: R/stream.R

n3d_streamR Documentation

Streaming Diarization

Description

Opens a streaming session: push audio as it arrives and get speaker probabilities for each completed chunk. The speaker cache keeps speaker numbering consistent across the whole stream.

Usage

n3d_stream(model, mode = "low_latency")

Arguments

model

A model from load_n3d.

mode

Streaming mode: "low_latency", "very_low_latency" or "ultra_low_latency".

Details

Latency is the audio a chunk waits for, its frames plus look-ahead: 1.04 s for "low_latency", 0.64 s for "very_low_latency" and 0.32 s for "ultra_low_latency", excluding compute time.

Every step re-encodes the speaker cache and FIFO queue (about 540 encoder frames) to score one chunk, so keeping up with live audio needs a GPU; on a CPU a step takes seconds.

Value

An n3d_stream session.

See Also

n3d_stream_push, n3d_stream_finish

Examples


if (n3d_exists()) {
  model <- load_n3d()
  mp3 <- system.file("samples", "Synapsis-Wonderland.mp3", package = "av")
  samples <- load_audio(mp3)
  s <- n3d_stream(model)
  probs <- list()
  for (start in seq(1, length(samples), by = 8000)) {
    piece <- samples[start:min(start + 7999, length(samples))]
    probs[[length(probs) + 1]] <- n3d_stream_push(s, piece)
  }
  probs[[length(probs) + 1]] <- n3d_stream_finish(s)
  probs_to_segments(do.call(rbind, probs))
}


n3d documentation built on Oct. 14, 2026, 5:08 p.m.