vadproc

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: BSD-2-Clause Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
	// SpeechActivityPeriod is the least time between two UserSpeakingFrames.
	// Speech is heard one short chunk at a time, and whatever is counting on the
	// user still being there needs to hear about it far less often than that, so
	// the frame is paced rather than sent per chunk.
	//
	// Leave it nil for 200ms. A zero duration sends one per chunk.
	SpeechActivityPeriod *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