vad

package
v0.10.0-dev.4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const ModeVeryAggressive mode = 3

ModeVeryAggressive is WebRTC VAD mode 3, the most restrictive level (fewest false positives), and the one the sync engine runs.

Variables

This section is empty.

Functions

func FramesBinary added in v0.4.0

func FramesBinary(ctx context.Context, pcm []int16, tuning Tuning) []float64

FramesBinary returns a binary {-1, +1} speech decision per 10ms frame under the given Tuning. PCM must be 8kHz mono s16le.

Named FramesBinary rather than FramesBinaryThresholdTuned: the old name listed the parameters it took, and they are all in Tuning now.

Types

type Tuning

type Tuning struct {

	// Mode is the WebRTC aggressiveness level.
	Mode mode
	// Threshold is the GMM log-likelihood ratio a frame must reach to be called
	// speech. NOT a duration: the safe and precise passes use 250 and 125.
	Threshold float64
	// OverhangFrames is how many frames the speech decision is held after the
	// ratio drops below Threshold — a frame COUNT, not a percentage.
	OverhangFrames int
	// AdaptScale scales noise-model adaptation; 0 freezes it, which is what movie
	// audio wants.
	AdaptScale float64
	// contains filtered or unexported fields
}

Tuning is the whole parameter set of one detection pass.

A struct rather than positional parameters, and the reason is the two float64s. Threshold and AdaptScale are the same type, so any transposition of them COMPILES and simply detects differently — `125, 10, 0` and `0, 10, 125` are both valid calls with wildly different behaviour and no error on either side. Mode and OverhangFrames are distinct types and would be caught; those two would not. Named fields make the mistake unwritable, which is the only guard available when the compiler cannot help.

The struct already existed for the two optional GMM knobs while four required ones stayed loose, so a caller passed tuning both ways in the same call. The two pointers lead because govet's fieldalignment counts leading pointer bytes; the exported knobs follow in the order a caller thinks about them.

Jump to

Keyboard shortcuts

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