vadproc

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package vadproc is the voice-activity-detection pipeline processor. It hosts a controller.Controller and turns what it hears into the raw VAD frames the turn subsystem consumes: VADUserStartedSpeakingFrame and VADUserStoppedSpeakingFrame on speech onset and offset, and UserSpeakingFrame for every chunk heard as speech. It does not decide turns, which is the turns package's job.

Place it just after the input transport. The detection itself, along with the resampling it needs and the watch for audio that stops arriving, lives in audio/vad/controller, so anything else needing the same detection can drive it without going through a pipeline. Frames are forwarded before detection runs over them, so audio keeps flowing and the rest of the pipeline is started before the parameters are reported.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// VAD detects voice activity. Required.
	VAD vad.Analyzer
	// AudioIdleTimeout is how long to wait, with the user speaking and no audio
	// arriving at all, before taking the speech to have stopped. It covers the
	// audio going away mid-utterance, a muted microphone being the usual case:
	// the detector never sees the silence that would have ended the speech, so
	// without this the user is left speaking for good.
	//
	// Leave it nil for one second. A zero duration turns the watch off.
	AudioIdleTimeout *time.Duration
}

Config configures a Processor.

type Processor

type Processor struct {
	*processor.Base
	// contains filtered or unexported fields
}

Processor is the VAD pipeline processor.

func New

func New(cfg Config) *Processor

New builds a VAD Processor. The VAD analyzer is required.

func (*Processor) Cleanup

func (p *Processor) Cleanup(ctx context.Context) error

Cleanup releases the controller and the processor.

func (*Processor) ProcessFrame

func (p *Processor) ProcessFrame(ctx context.Context, f frames.Frame, dir processor.Direction) error

ProcessFrame forwards the frame and then lets the controller run over it.

It forwards first so the StartFrame reaches everything downstream before the parameters are reported, and so audio keeps flowing without waiting on detection.

func (*Processor) Setup added in v0.1.0

func (p *Processor) Setup(ctx context.Context, s processor.Setup) error

Setup hands the controller its configuration, so the detector is told the pipeline's input rate before any audio arrives.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL